Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I launch a URL from my application on Android?

How can I code my Android application to start the web browser to display a given URL?

(I'd rather not embed a web browser component into my app, but rather want to start the Android web browser to show the URL.)

Thanks!

like image 561
RichieHindle Avatar asked Dec 04 '22 13:12

RichieHindle


2 Answers

Just use an Intent with the correct action and data:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.stackoverflow.com"));
startActivity(intent);
like image 164
Dan Lew Avatar answered Jan 13 '23 00:01

Dan Lew


In case if you have the website displayed on your view and you want it to make it clikable and direct user to particular website You can use:

android:autoLink="web"

In same way you can use different attributes of autoLink(email, phone, map, all) to accomplish your task...

like image 20
Saty Avatar answered Jan 13 '23 00:01

Saty