Intent.createChooser for ACTION_VIEW shows default browser only

北战南征 提交于 2020-01-25 17:26:47

问题


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);  

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.


回答1:


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.



来源:https://stackoverflow.com/questions/42826332/intent-createchooser-for-action-view-shows-default-browser-only

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!