Sending an Intent to browser to open specific URL


Question

I'm just wondering how to fire up an Intent to the phone's browser to open an specific URL and display it.

Can someone please give me a hint?

1
703
9/28/2016 7:02:00 PM

Accepted Answer

To open a URL/website you do the following:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

Here's the documentation of Intent.ACTION_VIEW.


Source: Opening a URL in Android's web browser from within application

1650
10/29/2016 4:01:51 AM

The short version

Intent i = new Intent(Intent.ACTION_VIEW, 
       Uri.parse("http://almondmendoza.com/android-applications/"));
startActivity(i);

should work as well...


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon