Android 调用平台功能 - 启动浏览器 支持file://
按着例子给自己的程序添加了启动浏览器的功能。
启动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" />
<data android:scheme="https" />
<data android:scheme="about" />
<data android:scheme="javascript" />
</intent-filter>
<!-- For these schemes where any of these particular MIME types
have been supplied, we are a good candidate. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:scheme="inline" />
<data android:mimeType="text/html"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="application/xhtml+xml"/>
<data android:mimeType="application/vnd.wap.xhtml+xml"/>
</intent-filter>
果然是没有file的scheme,加上程序就过了。
<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>
更多相关文章
- 程序包android.support.annotation不存在
- 程序性能优化之内存优化(三)下篇
- Android:从程序员到架构师之路Ⅲ_高焕堂
- android 裁剪图片完 程序会崩溃问题
- 【摘录】 Android中如何修改系统时间(应用程序获得系统权限)
- Android安装apk程序时出现Segmentation fault错误