views:

47

answers:

1

Hello,

I'm looking for a way to find out which browsers are installed on the Android Smartphone and their package names.

Why do I need it?

Well basically, my App reacts on certain URLs, i.e. http://bit.ly, so when the click such an he will get an choice in which App to open it. So far everything is working as intended.

If the user sets up this app as default for this kind of links, it will always open in this one without further asking the user. So far so good too. But by doing this, he will be completely unable to open this links in his browser.

So I need a way to send this intent directly to the browser, but to do so I have to know which app the user has set to be default for http/https scheme for example (as user can change it if there is more than 1 browser installed).

Sending the intend with

intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));

should't be a problem I think. The problem is, I can't send a standard intent für URLs, because my App would catch it again if set as default by the user.

A: 

should't be a problem I think

Hardwiring in the package and class names of code that is not yours is always a problem.

So I need a way to send this intent directly to the browser, but to do so I have to know which app the user has set to be default for http/https scheme for example (as user can change it if there is more than 1 browser installed).

Use PackageManager and queryIntentActivityOptions() to filter your activity out and get a list of other activities that the user can choose from.

CommonsWare
Thanks, that was a good hint in the right direction.
Tseng