Sash_KP
Sash_KP

Reputation: 5591

Android - "Open with" dialog still displays even after choosing an option from Intent.createChooser

I have an Imageview by clicking on which i need to open chooser which will show multiple apps which are eligible to open urls.I am doing something like this :

Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(article.getAndroidUrl()));
                if(Build.VERSION.SDK_INT>21){
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
                } else {
                intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY|Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                }
                            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivity(Intent.createChooser(intent, "Open Url Using"));

This works fine and open up the chooser. But among all the apps , if i choose "default browser" app of the device, then it again asks for "Open with" dialog. However if i choose other apps like chrome or firefox then it works fine and no 2nd open with dialog is shown.

So apart from default browser app, for other browser apps it works fine.

Question: Is there any known issue as such that even after using Intent.createChooser , for default browser, another "open with" dialog will open to ask again which app to use? If yes how to get rid of that?

Note: This doesn't happen in every device. For some devices this works fine but for other devices it asks for open with dialog again even after choosing an option from Intent.createChooser.

Upvotes: 1

Views: 593

Answers (1)

Mike M.
Mike M.

Reputation: 39191

The problem here seems to have been with the particular browsers themselves, not necessarily with your Intent chooser. When being redirected to the mobile site, basic browsers often will just handle this as a new request, and may show an Intent chooser of their own.

A workaround for this is to pass the mobile site URL explicitly, if possible, which would eliminate the need for the redirect, and open the site directly in the chosen browser.

Upvotes: 1

Related Questions