Fisher
Fisher

Reputation: 1794

How to open default browser

I want to make somethink like hyperlink. Right now, i created button, which opens new Activity with WebView. But i want to open a "globally" default web browser at specified url. How can i do this ?

Upvotes: 1

Views: 5757

Answers (2)

Patrick Kafka
Patrick Kafka

Reputation: 9902

You can fire a global intent that will be picked up by the browser

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

Also make sure to add the web permission to your manifest

<uses-permission android:name="android.permission.INTERNET" />

Upvotes: 8

Konstantin Burov
Konstantin Burov

Reputation: 69238

Just make and Intent and set the link as uri to the intent. Then use the intent to start activity. Try this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://stackoverflow.com")));

Upvotes: 2

Related Questions