Android 调用平台功能 - 启动浏览器 支持file://

本文详细介绍了在Android应用中如何调用浏览器来打开file://协议的链接。在尝试启动file://链接时遇到异常,问题在于Android内置浏览器的配置文件中未包含file协议。解决方法是在AndroidManifest.xml中添加对应的intent-filter,包含file协议,从而让浏览器能够正确处理file://类型的URI。
摘要由CSDN通过智能技术生成

按着例子给自己的程序添加了启动浏览器的功能。

启动http://的完全没有问题,启动file://就总是异常

最后发现问题出在了Android 浏览器的配置文件上

 

自己的调用程序:

 

  Uri uri = Uri.parse("file://data/data/test.html");       
  Intent it = new Intent(Intent.ACTION_VIEW, uri);       
  context.startActivity(it);     

Android 浏览器的配置文件:

 

packages/apps/Browser/AndroidManifest.xml

 

            <!-- For these schemes were not particular MIME type has been
                 supplied, we are a good candidate. -->
            <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="http" />
  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值