android webview call use chrome Browser
You may consider using Crosswalk android webview , which is based on same underlying engine as chromium/chrome.
It is packaged with your APK, so it is self-contained; You do not need chrome to be installed.
Its supposed to give you better performance than standard webview, with more built-in features.
Here is a hello world to get you started
mydeve
Updated on June 14, 2022Comments
-
mydeve almost 2 years
I had made a webapp which works fine in mobile chrome but in chromium I see some problem, so is it possible to call android chrome from app instead of webview in app.
I could not find any way to do it. 1: I don not care whether chrome is installed or not 2:i wrote below webview to open local html webview but i see few js issue with drag drop which works fine in android chrome browser
below is my code :
public class MainActivity extends Activity { private static final String URL = "file:///android_asset/index.html"; private WebView mWebView; @SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(Bundle savedInstanceState) { getWindow().requestFeature(Window.FEATURE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setWebViewClient(new WebViewClient()); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.getSettings().setRenderPriority(RenderPriority.HIGH); mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); final Activity activity = this; mWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { activity.setProgress(progress * 1000); } }); mWebView.loadUrl(URL); } @Override public void onConfigurationChanged(Configuration newConfig){ super.onConfigurationChanged(newConfig); } }
i wrote code which open url using chrome intent can i use such type of feature to use chrome as web view.
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.activity_main); String url = "http://www.google.com"; String packageName = "com.android.chrome"; Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setPackage(packageName); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //Activity context = null; List<ResolveInfo> activitiesList = getPackageManager().queryIntentActivities( browserIntent, -1); if(activitiesList.size() > 0) { // Found the browser on the device, launch it startActivity(browserIntent); } else { // The browser isn't installed, so we should prompt the user to get Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); playStoreIntent.setData(Uri.parse("market://details?id="+packageName)); playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(playStoreIntent); } }
-
mydeve over 9 yearswhat if i want to chrome packed with android device i will prefer asking user to install chrome if they do not have it
-
mydeve over 9 yearssee my 2nd code i tried opening it using crome intent but user gets out of app and chrome open , i want same look as webview not open browser
-
ashoke over 9 years@mour so you want to use chrome browser as a webview ? It is a browser, not webview, not sure if that will work. If you kick-off chrome intent, it will end up opening the chrome app, which is a full browser. Consider Crosswalk, it provides you a webview.