100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > android 浏览器打开本地html文件 Android浏览器如何打开本地html文件

android 浏览器打开本地html文件 Android浏览器如何打开本地html文件

时间:2024-05-30 12:16:33

相关推荐

android 浏览器打开本地html文件 Android浏览器如何打开本地html文件

满意答案

代码 如下:

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");

00分享举报

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。