14

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

Valentin Rocher
  • 11,667
  • 45
  • 59
apatki
  • 151
  • 2
  • 2
  • 6

4 Answers4

13

You have to import intent.

String url = "http://www.google.com";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
Anas Khan
  • 131
  • 1
  • 3
13

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"));
Valentin Rocher
  • 11,667
  • 45
  • 59
  • Will this for sure open the DEFAULT browser? I can't find that in the documentation. And I found an alternative answer that also supposedly opens the default browser: http://stackoverflow.com/a/23622337/2212770 – Wirling Mar 04 '16 at 13:25
3
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse(value));
startActivity(i);

value is your URL address.

Java Man
  • 1,854
  • 3
  • 21
  • 43
Niranj Patel
  • 32,980
  • 10
  • 97
  • 133
1

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

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268