Android - open pdf in external application

后端 未结 3 691
萌比男神i
萌比男神i 2021-01-15 03:39

i\'ve a pdf file in my app assets directory that i want open using an external app, so wrote my content provider and i\'m tryng to make it work but nothing...

here i

3条回答
  •  生来不讨喜
    2021-01-15 04:05

    I am new to android development and spent the whole day looking for the reason that my locally stored PDF could not be opened by external apps. I am glad having found this thread.

    In the meantime Marco got it working and describes it here. Beware: Italian language- Google translation service might help ;-)

    http://www.marcofaion.it/?p=7
    http://web.archive.org/web/20111020204554/http://www.marcofaion.it/?p=7

    Additional notes to his howto for beginners:

    The line Marco mentions to be inserted in the Manifest.xml

    
    

    should be inserted within the tag.

    And if you plan to have custom filenames you should exchange

    InputStream is = am.open("file.pdf");
    

    with

    InputStream is = am.open(uri.getLastPathSegment());
    

    PDF files have to be put into already existing folder assets in your project (especially not in any newly added folder res/assets or sth.)! =)

提交回复
热议问题