Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Open a URL in a Browser [duplicate]

Tags:

android

Possible Duplicate:
How can I open a URL in Android’s web browser from my application?

I've been trying to find out how to create an intent that will open the specified URL in a Specified browser. Browser may not always be the default one. But i am unable to do so.

like image 242
Harshit Dubey Avatar asked Jun 08 '11 10:06

Harshit Dubey


People also ask

How do I open a URL with intent?

To open a URL/website you do the following: String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i.


1 Answers

Use the Intent.ACTION_VIEW constant as Intent action and the url as data.

final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
activity.startActivity(intent);

Note the URL must be a full URL (starting with either http:// or https://) so check in your code that the URL is not a short form such as www.google.com if it is user-defined.

like image 65
Vincent Mimoun-Prat Avatar answered Oct 19 '22 16:10

Vincent Mimoun-Prat