I\'m currently testing a webapp developed with lots of jQuery animations, and we\'ve noticed really poor performance with the built-in web browser. While testing in Chrome,
All the proposed solutions doesn't work for me anymore. Thanks to @pixelbandito, he pointed me to the right direction. I've found the next constant in the chrome sources
public static final String GOOGLECHROME_NAVIGATE_PREFIX = "googlechrome://navigate?url=";
And the next usage:
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse("googlechrome://navigate?url=chrome-native://newtab/"));
So the solution is (note the url should not be encoded)
void openUrlInChrome(String url) {
try {
try {
Uri uri = Uri.parse("googlechrome://navigate?url="+ url);
Intent i = new Intent(Intent.ACTION_VIEW, uri);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
} catch (ActivityNotFoundException e) {
Uri uri = Uri.parse(url);
// Chrome is probably not installed
// OR not selected as default browser OR if no Browser is selected as default browser
Intent i = new Intent(Intent.ACTION_VIEW, uri);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
} catch (Exception ex) {
Timber.e(ex, null);
}
}