Android : Open a URL in a Browser [duplicate]
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. Brow开发者_运维技巧ser may not always be the default one. But i am unable to do so.
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.
try this :
String url = "your URL";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(browserIntent);
You can use any of them, also read the Link
Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.google.com"));
startActivity(browserIntent);
or
String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url)); startActivity(i);
精彩评论