代码 如下:
Intent intent=new Intent();
intent.setAction("android .intent.action.VIEW");
Uri CONTENT_URI_BROWSERS = Uri.parse("content://com.android.htmlfileprovider/sdcard/123.html");
intent.setData(CONTENT_URI_BROWSERS);
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");
startActivity(intent);
假设要打开的本地html文件 存放在如下路径 /sdcard/123.html
如果出现错误:
Unable to find explicit activity class {
com.google.android.browser/com.android.browser.BrowserActivity};
have you declared this activity in your AndroidManifest.xml?
用
intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
代替
intent.setClassName("com.android.browser", "com.android.browser.BrowserActivity");