开发者

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

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


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);        


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜