发送意图到浏览器以打开特定的URL [英] Sending an Intent to browser to open specific URL

查看:99
本文介绍了发送意图到浏览器以打开特定的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何向手机浏览器启动一个Intent以打开特定的URL并显示它.

有人可以给我一个提示吗?

解决方案

要打开URL/网站,请执行以下操作:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

这是Intent.ACTION_VIEW文档.


来源:从应用程序内部在Android的网络浏览器中打开URL

I'm just wondering how to fire up an Intent to the phone's browser to open an specific URL and display it.

Can someone please give me a hint?

解决方案

To open a URL/website you do the following:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);

Here's the documentation of Intent.ACTION_VIEW.


Source: Opening a URL in Android's web browser from within application

这篇关于发送意图到浏览器以打开特定的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆