Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

like image 630
Charles Yeung Avatar asked Dec 16 '22 13:12

Charles Yeung


2 Answers

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);        
like image 155
fleetway76 Avatar answered May 12 '23 04:05

fleetway76


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.

like image 29
dst Avatar answered May 12 '23 06:05

dst