Intent.createChooser for ACTION_VIEW shows default

2019-09-19 08:16发布

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.

app chooser dialog after clicking on link in notification

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条回答
我只想做你的唯一
2楼-- · 2019-09-19 09:00

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.

查看更多
登录 后发表回答