android安装自动打开网页,Android调用系统自带浏览器打开网页的实现方法
Android调用系统自带浏览器打开网页的实现方法
在Android中可以调用自带的浏览器,或者指定一个浏览器来打开一个链接。只需要传入一个uri,可以是链接地址。
启动android默认浏览器
在Android程序中我们可以通过发送隐式Intent来启动系统默认的浏览器。如果手机本身安装了多个浏览器而又没有设置默认浏览器的话,系统将让用户选择使用哪个浏览器来打开连接。
Uri uri = Uri.parse("");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
使用以上三行代码就能调用系统自带浏览器。
启动指定浏览器打开
在Android程序中我们可以通过发送显式Intent来启动指定的浏览器。例如我手机安装了多个浏览器:QQ浏览器、chrome浏览器、uc浏览器。我可以指定用某个浏览器打开这个链接。例如打开QQ浏览器如下代码:
Uri uri = Uri.parse("");
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
//intent.setClassName("com.UCMobile","com.uc.browser.InnerUCMobile");//打开UC浏览器
intent.setClassName("com.tencent.mtt","com.tencent.mtt.MainActivity");//打开QQ浏览器
startActivity(intent);
用uc浏览器打开只需要把打开qq浏览器
发布者:admin,转转请注明出处:http://www.yc00.com/news/1699841594a939041.html
评论列表(0条)