在Android中,我如何可以强制使用特定的浏览器中打开一个URI,而不弹出的“选择浏览器的名单? [英] In android, How can I force open a URI using a specific browser, without popping up the 'choose browser' list?

查看:205
本文介绍了在Android中,我如何可以强制使用特定的浏览器中打开一个URI,而不弹出的“选择浏览器的名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的Andr​​oid设备上的多个浏览器。我可以使用下面的code打开一个URI使用默认的Andr​​oid浏览器:

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
  • 在开放的Andr​​oid的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.

这篇关于在Android中,我如何可以强制使用特定的浏览器中打开一个URI,而不弹出的“选择浏览器的名单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆