简体   繁体   中英

How to open a specific browser from an android app

I want to open a url in a browser from an Android app. Thats pretty straightforward: How can I open a URL in Android's web browser from my application?

But how can I open the url in a specific browser, if it exists.

if(user has chrome)
    open url in chrome;
else if(user has opera)
    open url in opera;
else
    open url in default browser;

is this possible?

You shouldn't force the user to use a specific application for a generic event like opening a URL. Android is designed to give the user the freedom to use whatever app they want.

This is why when you click URLs on your phone, you will get a dialog asking which application you want to use for that action. You can select an application to always handle that type of action, but apps should not choose for you.

Generally speaking Tanis right, you shouldn't do such things for Android.

However, if you really need to. You can use Intent.setPackage . This will send indent to appropriate application package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM