What is the intent to launch any website link in Google Chrome What is the intent to launch any website link in Google Chrome google-chrome google-chrome

What is the intent to launch any website link in Google Chrome


It seems you're looking for the new Android Intents link that will create and explicit intent for the device for a link.

<a href="intent://<URL>#Intent;scheme=http;package=com.android.chrome;end">

works for me.so

<a href="intent://stackoverflow.com/questions/29250152/what-is-the-intent-to-launch-any-website-link-in-google-chrome#Intent;scheme=http;package=com.android.chrome;end"> 

will take you to this question in Chrome.Note that the scheme is specified separately so if you want to launch https links, you'd have to change scheme to scheme=https

But as everyone is saying, an explicit Chrome intent is a very non-Android thing to do. A better way would be to specify the ACTION_VIEW action like so:

<a href="intent://stackoverflow.com/questions/29250152/what-is-the-intent-to-launch-any-website-link-in-google-chrome#Intent;scheme=http;action=android.intent.action.VIEW;end;">

Source: The same page you linked

Thanks, I learned something today!


Below code make launch urls in webview including intent:// url scheme in Android.

@Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) {    if (url != null) {        if (url.startsWith("http://") || url.startsWith("https://")) {            view.loadUrl(url);        } else if (url.startsWith("intent://")) {            try {                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);                Intent existPackage = getPackageManager().getLaunchIntentForPackage(intent.getPackage());                if (existPackage != null) {                    startActivity(intent);                } else {                    Intent marketIntent = new Intent(Intent.ACTION_VIEW);                    marketIntent.setData(Uri.parse("market://details?id=" + intent.getPackage()));                    startActivity(marketIntent);                }                return true;            } catch (Exception e) {                e.printStackTrace();            }        } else if (url.startsWith("market://")) {            try {                Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);                if (intent != null) {                    startActivity(intent);                }                return true;            } catch (URISyntaxException e) {                e.printStackTrace();            }        } else { // unhandled url scheme             view.getContext().startActivity(                    new Intent(Intent.ACTION_VIEW, Uri.parse(url)));        }        return true;    } else {        return false;    }}


I have tested below code with Nexus 6 with Chrome and Mozilaa installed and it works great,

    String url = "http://www.stackoverflow.com";    Intent i = new Intent();    i.setPackage("com.android.chrome");    i.setAction(Intent.ACTION_VIEW);    i.setData(Uri.parse(url));    startActivity(i);

This will give error if Chrome is not installed in your device. So put check for package availability.