Charles Yeung
Charles Yeung

Reputation: 38805

Android - Call default browser with and redirect to a designated url

Hi
I want to write an app to call default browser and redirect to a designated url. Any suggestion to 1)call the default browser, 2)redirect to a designated url.

Thanks

Upvotes: 4

Views: 10907

Answers (2)

fleetway76
fleetway76

Reputation: 1640

you just want to launch an ACTION_VIEW intent with the Uri of the webpage as your data element :

Intent httpIntent = new Intent(Intent.ACTION_VIEW);
httpIntent.setData(Uri.parse("http://www.bbc.co.uk"));

startActivity(httpIntent);        

Upvotes: 11

dst
dst

Reputation: 1788

To open the default browser use an Intent with the action VIEW. To tell the browser which page to load us the data-part of the Intent.

Example:

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

Since this is a basic task in Android you might want to read some basics about Intents in Android.

Upvotes: 2

Related Questions