admin管理员组

文章数量:1619183

打开本地的html文件的时候,一定要指定某个浏览器,具体示例代码如下
  Intent intent = new Intent();
  intent.setAction("android.intent.action.VIEW");    
  Uri content_url = Uri.parse("content://com.android.htmlfileprovider/sdcard/test.html");   
  intent.setData(content_url);           
  intent.setClassName("com.android.browser","com.android.browser.BrowserActivity");   
  startActivity(intent);

  关键点是调用了”content“这个filter。


  如果想以”file://sccard/test.html“的方式打开,也是可以的,不过需要修改,默认的浏览器设置是没有对”file“这个进行解析的,如果要让你的默认android浏览器有这个功能需要自己到android源码修改manifest.xml文件,然后自己编译浏览器代码生成相应的apk包来重新在机器上安装。
  大体的步骤如下:
  1、打开 packages/apps/Browser/AndroidManifest.xml文件把加到相应的<intent-filter>后面就可以了
  <intent-filter>
                  <action android:name="android.intent.action.VIEW" />
                  &

本文标签: 浏览器页面androidhtml