我在我的文件夹"/mnt/sdcard/Download/baby_details.doc“中有一个word文档(稍后我也会构建一个pdf文档,但现在word文档将被打开),并且我设置为打开这个文档的应用程序类型是" application /msword”。
在我的eclipse LogCat中,我观察了原生android活动如何打开Word文档,结果如下所示
Starting: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/Download/per-general-business-letter.doc typ=application/msword flg=0x10000000 cmp=com.qo.android.moto/com.qo.android.quickoffice.QuickofficeDispatcher } from pid 24132
Starting: Intent { act=android.intent.action.VIEW dat=file:///mnt/sdcard/Download/per-general-business-letter.doc typ=application/msword flg=0x1 cmp=com.qo.android.moto/com.qo.android.quickword.Quickword } from pid 1591
Start proc com.qo.android.moto:Quickword for activity com.qo.android.moto/com.qo.android.quickword.Quickword: pid=2452 uid=10010 gids={3003}所以我试着用来打开文档
Bundle bundle = new Bundle();
bundle.putString("dat", "/mnt/sdcard/Download/baby_details.doc");
bundle.putString("typ", "application/msword");
Intent docClient = new Intent(Intent.ACTION_VIEW);
docClient.putExtras(bundle);
docClient.setClassName("com.qo.android.moto", "com.qo.android.quickword.Quickword");
startActivityForResult(docClient, WORD_APP);但是我得到了一个未知源,我还尝试将setClassName更改为
docClient.setClassName("com.qo.android.moto", "com.qo.android.quickoffice.QuickofficeDispatcher");仍然会得到相同的错误。
我想知道是否有人使用本机QuickOffice活动打开了word/pdf/xls?
谢谢,萨娜。
发布于 2011-03-25 04:06:03
不要把"dat“和"type”放在一起;使用Intent.setType和intent.setData (或者只使用intent.setDataAndType。并确保您用于数据的URI与系统期望的URI (file://)匹配。
https://stackoverflow.com/questions/5424428
复制相似问题