I have multiple browsers on my android device. I can use the following code to open a URI using the default android browser:
String packageName = "com.android.browser";
String className = "com.android.browser.BrowserActivity";
Intent internetIntent = new Intent(Intent.ACTION_VIEW);
internetIntent.addCategory(Intent.CATEGORY_LAUNCHER);
internetIntent.setClassName(packageName, className);
startActivity(internetIntent);
How can I accomplish the same using a specified browser that is installed on my device, say Opera.
Thanks very much.
you need to set packageName and className to the package and class names of the browser activity.
For example, for Opera Mini, you need to do the following:
For other browsers, you can find the package and class name by doing the following:
In Android Logcat, you will see something like this:
The class name will be shown in the ‘cmp’ attribute: cmp=com.opera.mini.android/.Browser
In this case, the package name is com.opera.mini.android and the class name is com.opera.mini.android.Browser.