开发者

Launching a pdf asset from android menu?

I have included a file c开发者_Go百科alled "Manual.pdf" in my assets folder. I have created a menu button called "Help". I want the user to be able to go to the menu, press on the Help button, and launch the Manual.pdf file in whatever viewer the phone has installed.

I have read for a few hours on this site and other sites, but I just can't get the file to launch.

Thanks for any help.


There is no unified PDF reader for Android Devices. I assume that in the course of your research you would have found that, you could use an implicit intent to invoke a pdf reader if it does exists.

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(file));
intent.setType("application/pdf");

It works in some devices and fails in some other devices. ( so please check availability of intent using the package manager). If you are targeting a particular device then you could get the corresponding Activity Object and use an Implicit Intent.(com.htc.pdfreader for HTC Phones).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜