Trying to open a Word doc from my app in Xoom(Android 3.0), but getting "Unknown Source"
I have a word document(also later I would be building a pdf too, but right now word document is to be opned) in my folder "/mnt/sdcard/Download/baby_details.doc" and the application type I set to open this document is "application/msword".
In my eclipse LogCat I was watching how a Word document is opened by the native android activity and I get to see the result as
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}
so I tried to open the doc with
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);
but I get a Unknown Source, I also tried changing the setClassName to
docClient.setClassName("com.qo.android.moto", "com.qo.android.quickoffice.QuickofficeDispatcher");
and still get the same error.
I would like to know if anyone has used the native QuickOffice activity to open a word/pdf/xls?
Thanks, Sana.
Don't put "dat" and "type" in a bundle; use Intent.setType
and intent.setData
(or just use intent.setDataAndType
. And make sure the URI you use for the data matches what the system expects (file://
).
精彩评论