与Android浏览器中打开本地的html文件 [英] opening local html file with Android Browser

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

问题描述

我试图用下面的code。使用默认浏览器打开本地的HTML文件:

i'm trying to open a local html file using the default browser using the following code:

Uri uri = Uri.fromFile(file);
Intent browserIntent = new Intent(Intent.ACTION_VIEW).setData(uri);
startActivity(browserIntent);

但我发现以下异常:

but i'm getting the following exception:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=file:///sdcard/SolveDroid/solution.html }

我很困惑 - 我应该创建活动喊得网络beowser?是不是应该只需要调用它的活动呢?

i'm confused - should i create an activity to hande the web beowser? isn't it supposed to just call its activity?

请指教:)

更新: 同code的作品,如果我通过一个URL,如下所示:  开放的URI = Uri.parse(http://www.metalist.co.il);

UPDATE: the same code works if i pass a URL like so: Uri uri = Uri.parse("http://www.metalist.co.il");

推荐答案

我发现这个问题......只是需要加入

I found an answer for this problem... just needed to add

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

我用它的文件://URI使用 Uri.fromfile(文件)和它的作品(安卓v.2.2.1)

i used it with the "file://" uri by using Uri.fromfile(file) and it works (Android v.2.2.1)

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

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