Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android launching specific url with specific browser

Launching a specific browser by icon is done with a ACTION_MAIN. Launching a specific url using default browser is done with a ACTION_VIEW.

What if you want to open a specific url in a specific browser?

like image 665
Eitan Schwartz Avatar asked Dec 27 '22 02:12

Eitan Schwartz


2 Answers

If you know the package name and the class name of the browser,you can use Intent.setClassName (String packageName, String className). looks like:

Intent i=new Intent(ACTION_VIEW, url);
i.setClassName("com.test.browser","BrowserActivity");
startActivity(i);
like image 76
farmer.chs Avatar answered Jan 10 '23 20:01

farmer.chs


You can even call the specific browser via its package name.
Like this;

Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://www.google.co.com"));
intent.setPackage("org.mozilla.firefox");
startActivity(intent);
like image 42
Anshul chhabra Avatar answered Jan 10 '23 19:01

Anshul chhabra