用于ACTION_VIEW的Intent.createChooser仅显示默认浏览器 [英] Intent.createChooser for ACTION_VIEW shows default browser only
问题描述
我正在尝试使用Intent.createChooser显示应用选择器对话框,该对话框将列出用户电话中所有可用的Web浏览器. 我正在使用以下代码:
I am trying to show a app chooser dialog using Intent.createChooser, that will list all available web browsers in user's phone. I'm using the code below:
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse(category));
// Create and start the chooser
Intent chooser = Intent.createChooser(browserIntent, "Open with...");
pIntent = PendingIntent.getActivity(helperMethodContext, 0, chooser, PendingIntent.FLAG_UPDATE_CURRENT);
Log.d("HelperMethods: ", "video chat url: " + category);
我正在android 6上对此进行测试.我的手机具有3个浏览器,默认浏览器,chrome和firefox.当我运行它并单击链接(通知)时,将打开应用选择器对话框,但仅显示默认浏览器.它不显示Chrome或Firefox.
I am testing this on android 6. My phone has 3 browsers, default browser, chrome and firefox. When i run it and click on the link(the notification), app chooser dialog opens but only shows default browser. It doesn't show chrome or firefox.
我已经检查了手机中的默认应用程序设置,并且没有默认浏览器.当我单击默认浏览器时,它将打开并显示一个应用选择器对话框,其中显示了我已安装在手机上的所有浏览器应用.
I have checked default apps settings in my phone and there is no default browser. When i click default browser it opens with an app chooser dialog showing all the browser apps i have installed on my phone.
有人可以告诉我我要去哪里错了.
Pls can someone tell me where am i going wrong.
推荐答案
您拥有哪种类型的uri非常重要.是http,https还是其他方案.您的情况是Uri.parse(category)
.例如,firefox可以处理以下方案:http
,https
,file
,about
,javascript
,package
.以及具有mimeType的数据:text/html
,text/plain
和application/xhtml+xml
.
There is so important what type of uri do you have. Is it http, https or other scheme. In your case it's Uri.parse(category)
. For example firefox can handle scheme like: http
, https
, file
, about
, javascript
, package
. And also data with mimeType: text/html
, text/plain
and application/xhtml+xml
.
这篇关于用于ACTION_VIEW的Intent.createChooser仅显示默认浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!