如何打开存储在SD卡中的浏览器中的.doc文件? [英] How to open a .doc file stored in SD card in browser?

查看:256
本文介绍了如何打开存储在SD卡中的浏览器中的.doc文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我存储在SD卡中的.doc文件。我必须使用浏览器打开它。
我用

 意向意图=新的Intent();
档案文件=新的文件(/ SD卡/ ValidateLibrary.doc);
intent.setDataAndType(Uri.fromFile(文件),text / html的);

在manifest文件中我写道:

 <活动机器人:TextFileShowNAME =>
    &所述;意图滤光器>
              <作用机器人:名字=myaction/>
    &所述; /意图滤光器>
< /活性GT;

但它打开邮件撰写。

我要打开一个浏览器里面的ValidateLibrary.doc文件。
我该怎么做呢?


解决方案

  

我必须使用浏览器打开它。


我不知道在行星表面的任何Web浏览器,其他的或许比IE浏览器,这是能够显示本地Microsoft Word文档。我不知道任何Web浏览器为Android,它能够显示本地Microsoft Word文档中。

至于你的Java源代码code片断:


  • 的text / html 不是MIME类型为Microsoft Word。

  • 决不要硬code路径如 / SD卡,特别是因为它是错误的许多设备。使用 Environment.getExternalStorageDirectory()来获得在外部存储的根源。

  • 只需创建一个意图对你一点好处。如果你想使用的用户可能已经安装了一些文档查看器来显示Word文档,您需要在意图 ACTION_VIEW C $ C>的构造函数,然后设置路径/类型,你在做什么,然后调用 startActivity()


  

在manifest文件中我写道:


我不知道这是为什么在这里。这当然没有什么明显的与你的Java code片段,它有什么明显的做了这个问题。


  

我要打开一个浏览器里面的ValidateLibrary.doc文件。我该怎么做呢?


第1步:写一个Web浏览器

第2步:增强您的Web浏览器能够显示Microsoft Word文档。这可能涉及你有许可一些专利,可能会采取一些开发人员十年来写。

第三步:说服用户安装的Web /字浏览器

这将是简单的为您只需启动了一个 ACTION_VIEW 意图上的Word文档,然后直接用户到市场上安装一些处理Word文档的第三方应用程序,如果用户没有安装的。

I have a .doc file stored in the SD card. I have to open it using the browser. I used

Intent intent = new Intent();
File file = new File("/sdcard/ValidateLibrary.doc"); 
intent.setDataAndType( Uri.fromFile(file),"text/html");

in the manifest file i wrote:

<activity android:name=".TextFileShow">
    <intent-filter>
              <action android:name="myaction"/>
    </intent-filter>
</activity>

But it opens the "message compose".

I have to open the ValidateLibrary.doc file inside a browser. How do i do that?

解决方案

I have to open it using the browser.

I am not aware of any Web browser on the face of the planet, other than perhaps Internet Explorer, that is capable of natively displaying Microsoft Word documents. I am not aware of any Web browser for Android that is capable of natively displaying Microsoft Word documents.

With regards to your Java source code snippet:

  • text/html is not the MIME type for Microsoft Word.
  • Never hardcode paths like /sdcard, particularly since it is wrong for many devices. Use Environment.getExternalStorageDirectory() to get at the root of external storage.
  • Just creating an Intent will do you little good. If you want to display a Word document using some document viewer that the user might have installed, you would need to use ACTION_VIEW in the Intent constructor, then set the path/type as you are doing, then call startActivity().

in the manifest file i wrote:

I have no idea why this is here. It certainly has nothing obvious to do with your Java code snippet, and it has nothing obvious to do with this question.

I have to open the ValidateLibrary.doc file inside a browser. How do i do that?

Step #1: Write a Web browser.

Step #2: Augment your Web browser to be able to display Microsoft Word documents. This may involve you having to license some patents and will probably take a few developer-decades to write.

Step #3: Convince users to install your Web/Word browser.

It would be simpler for you to simply start up an ACTION_VIEW Intent on the Word document, then direct users to the Market to install some third-party application that handles Word documents if the user does not have one installed.

这篇关于如何打开存储在SD卡中的浏览器中的.doc文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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