开发者

How to open default browser

I want to make somethink like hyperlink. Right now, i created button, which opens new Activity with WebView开发者_C百科. But i want to open a "globally" default web browser at specified url. How can i do this ?


You can fire a global intent that will be picked up by the browser

Uri uri = Uri.parse( "http://www.google.com" );
startActivity( new Intent( Intent.ACTION_VIEW, uri ) );

Also make sure to add the web permission to your manifest

<uses-permission android:name="android.permission.INTERNET" />


Just make and Intent and set the link as uri to the intent. Then use the intent to start activity. Try this:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜