Android 如何调用系统默认浏览器访问
来源:互联网 发布:达内java飞机大战图片 编辑:程序博客网 时间:2024/05/16 12:40
转自:http://hi.baidu.com/519177819/item/853df8228a8c0c182b0f1cbe
一、启动android默认浏览器
Intent intent= new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://www.cnblogs.com");
intent.setData(content_url);
startActivity(intent);
这样子,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.cnblogs.com");
intent.setData(content_url);
intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");
startActivity(intent);
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);
关键点是调用了”content“这个filter。
以前有在win32编程的朋友,可能会觉得用这种形式”file://sccard/help.html“是否可以,可以很肯定的跟你说,默认的浏览器设置是没有对”file“这个进行解析的,如果要让你的默认android浏览器有这个功能需要自己到android源码修改manifest.xml文件,然后自己编译浏览器代码生成相应的apk包来重新在机器上安装。
大体的步骤如下:
1、打开 packages/apps/Browser/AndroidManifest.xml文件把加到相应的<intent-filter>后面就可以了
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
</intent-filter>
2、重新编译打包,安装,这样子,新的浏览器就支持”file“这个形式了
- Android如何调用系统默认浏览器访问
- Android 如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android开发_如何调用系统默认浏览器访问
- Android 调用系统默认浏览器
- 如何实现使用C/C++直接调用系统默认浏览器?
- 应用程序调用系统默认浏览器
- android实现程序启动直接调用系统默认浏览器
- Android调用系统浏览器
- XX教你玩 MiniPC (五) Mk908 bootimg分析
- 云上的故事
- 转:我的学校学习和工作经历
- Cookie的格式及组成
- android_基础_图片处理_在imageview上画图
- Android 如何调用系统默认浏览器访问
- 使用 SignalR 实现实时的提醒
- Juqery 雪花飘落插件
- jQuery插件 -- 表单验证插件jquery.validate.js
- EasyPlat.net V5手册目录
- 启联推出全球首款GPS微型平台,可运行在X86或ARM架构的服务器上
- R-各种分布函数
- windows 下android sdk tools升级不了问题解决
- Prim算法和Kruskal算法