Home » Android » android – How to open default browser

android – How to open default browser

Posted by: admin May 14, 2020 Leave a comment

Questions:

Can we make use of default browser instead of the WebView browser
Is there ny API for the default browser…..

or we have to compulsory create our own browser through WebView

How to&Answers:

You can use an Intent with ACTION_VIEW to open the browser with your URL. Would be something like that :

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));

Answer:

You have to import intent.

String url = "http://www.google.com";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);

Answer:

Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse(value));
startActivity(i);

value is your URL address.

Answer:

This is a late answer but if you just need to open the default browser without an url you can use about:blank, i.e.:

Intent blankIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("about:blank"));
startActivity(blankIntent);

Tested with:

Stock Browser, Chrome, Firefox and Opera for Android