我有我的Android设备上的多个浏览器。我可以使用下面的code打开一个URI使用默认的Android浏览器:
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.
非常感谢。
您需要设置的packageName和类名的浏览器活动的包和类名。
you need to set packageName and className to the package and class names of the browser activity.
例如,对于Opera Mini的,你需要做到以下几点:
For example, for Opera Mini, you need to do the following:
String packageName = "com.opera.mini.android";
String className = "com.opera.mini.android.Browser";
Intent internetIntent = new Intent(Intent.ACTION_VIEW);
internetIntent.addCategory(Intent.CATEGORY_LAUNCHER);
internetIntent.setClassName(packageName, className);
startActivity(internetIntent);
有关其他浏览器,你可以通过执行查找包和类名如下:
For other browsers, you can find the package and class name by doing the following:
在android手机连接到PC 在开放的Android的logcat 从手机启动浏览器在Android的logcat中,你会看到这样的事情:
In Android Logcat, you will see something like this:
07-22 14:06:14.662: INFO/ActivityManager(148): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.opera.mini.android/.Browser }
类的名称将在CMP属性显示出来:CMP = com.opera.mini.android / .Browser
The class name will be shown in the 'cmp' attribute: cmp=com.opera.mini.android/.Browser
在这种情况下,包名是com.opera.mini.android和类名称是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.
上一篇:在ExpandableListView组项目的Android LongClickListener项目、ExpandableListView、Andr、LongClickListener
下一篇:如何构建SQLDECIMAL数据类型,指定precision和规模的实例数据类型、实例、规模、SQLDECIMAL