Android开发之浏览器用法实例详解(调用uc,opera,qq浏览器访问网页

2019-12-10 19:23:35王旭
易采站长站为您分析Android开发之浏览器用法,结合实例形式详细分析了Android调用浏览器的具体步骤与相关使用技巧,需要的朋友可以参考下  

本文实例讲述了Android开发之浏览器用法。,具体如下:

一、启动android默认浏览器

Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.easck.com/pre>
	
	

这样子,android就可以调用起手机默认的浏览器访问。

二、指定相应的浏览器访问

1、指定android自带的浏览器访问

("com.android.browser":packagename;"com.android.browser.BrowserActivity":启动主activity)

Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.easck.com/pre>
	
	

2、启动其他浏览器(当然该浏览器必须安装在机器上)

只要修改以下相应的packagename 和 主启动activity即可调用其他浏览器

复制代码 intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");

 

uc浏览器:"com.uc.browser", "com.uc.browser.ActivityUpdate"
opera:"com.opera.mini.android", "com.opera.mini.android.Browser"
qq浏览器:"com.tencent.mtt", "com.tencent.mtt.MainActivity"

三、打开本地html文件

打开本地的html文件的时候,一定要指定某个浏览器,而不能采用方式一来浏览,具体示例代码如下

Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("content://com.android.htmlfileprovider/sdcard/help.html");
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
startActivity(intent);