Videos
Yes, but if it's not installed on the system you'll run into an ActivityNotFoundException. If it's not available, you should launch through the normal browser:
String url = "http://mysuperwebsite";
try {
Intent i = new Intent("android.intent.action.MAIN");
i.setComponent(ComponentName.unflattenFromString("com.android.chrome/com.android.chrome.Main"));
i.addCategory("android.intent.category.LAUNCHER");
i.setData(Uri.parse(url));
startActivity(i);
}
catch(ActivityNotFoundException e) {
// Chrome is not installed
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(i);
}
Here is a solution without a try catch, if chrome is installed, it will be used. Otherwise, it will go to the device default
void open(Activity activity, String url) {
Uri uri = Uri.parse("googlechrome://navigate?url=" + url);
Intent i = new Intent(Intent.ACTION_VIEW, uri);
if (i.resolveActivity(activity.getPackageManager()) == null) {
i.setData(Uri.parse(url));
}
activity.startActivity(i);
}
The basic syntax for an intent based URI is as follows:
intent:
HOST/URI-path // Optional host
#Intent;
package=[string];
action=[string];
category=[string];
component=[string];
scheme=[string];
end;
Parsing details available in the Android source.
To launch the ZXing barcode scanner app you can encode your href as follows:
<p>
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end">Take a qr code</a><br>
<a href="intent://scan/?ret=http%3A%2F%2Fexample.com#Intent;scheme=zxing;package=com.google.zxing.client.android;end">Take a qr code = 10px x 10px</a><br>
<a href="intent:play/?mediaset=android-phone-rtmp-high&playlisturl=http://www.bbc.co.uk/iplayer/playlist/bbc_one_london#Intent;scheme=bbcmediaplayer;package=air.uk.co.bbc.android.mediaplayer;end">Launch BBC</a>
</p>
The Android manifest defines the scheme to be zxing, the package to be com.google.zxing.client.android and the host data to be scan.
If the activity you are invoking via an intent contains extra data, these too can be included.
Only activities that have category filter android.intent.category.BROWSABLE are able to be invoked using this method as it indicates that the application is safe to open from the browser.
This is not generically possible. If other apps have a custom URL handler then you can open that URL, but otherwise you can't.