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

启动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>

更多相关文章

  1. 程序包android.support.annotation不存在
  2. 程序性能优化之内存优化(三)下篇
  3. Android:从程序员到架构师之路Ⅲ_高焕堂
  4. android 裁剪图片完 程序会崩溃问题
  5. 【摘录】 Android中如何修改系统时间(应用程序获得系统权限)
  6. Android安装apk程序时出现Segmentation fault错误

随机推荐

  1. android HTTP post方法时,如何使用cookies
  2. android 项目收获01
  3. Android(安卓)App第一次启动或者更新或第
  4. [Android]Generating Keys
  5. Android将Uri转化为文件路径的方法
  6. Android(安卓)Question - “Id cannot be
  7. Android的字符编码转换问题,Unicode,GB2312
  8. Android(安卓)圆角图片 圆形图片
  9. Android(安卓)– Multithreading in a UI
  10. Android(安卓)调用系统播放器