在android 3.x中打开带有android浏览器的本地html文件 [英] opening-local-html-file-with-android-browser in android 3.x

查看:306
本文介绍了在android 3.x中打开带有android浏览器的本地html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在android 2.x上,我可以使用解决方案

with android 2.x i could use the solution

browserIntent.setClassName("com.android.browser", "com.android.browser.BrowserActivity") 

在帖子中解决:

使用Android浏览器打开本地html文件

但是在android 3.2上我有这个错误:

but with android 3.2 i have this error:

Unable to find explicit activity class 
(com.android.browser/com.android.browser.BrowserActivity); 
have you declared this activity in your AndroidManifest.xml?

我认为Android 3.x中不存在类com.android.browser.BrowserActivity

I think that the class com.android.browser.BrowserActivity doesn't exist in Android 3.x

有解决方案吗?

推荐答案

不是令人满意的解决方案,但在演示应用程序中,我还使用了以下代码:

Not a satisfying solution, but in a demo application I alternatively used the following code:

String url = "content://com.android.htmlfileprovider/sdcard/mydir/myfile.html";
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(url), "text/html");
startActivity(intent);

通常至少有两幅作品之一.

Usually at least one of the two works.

https: //github.com/nicolas-raoul/OxygenGuide-Android/blob/master/src/org/github/OxygenGuide/MainActivity.java#L69

这篇关于在android 3.x中打开带有android浏览器的本地html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆