Sukhpal Singh
Sukhpal Singh

Reputation: 730

Open pdf in external app

I have and android app. It has a pdf in assets folder. I written a code to view this pdf in external app(like adobe pdf viewer). It is working fine but problem is that there is Share option in Adobe pdf viewer. I dont want that user can distribute this pdf.

My problem is that there is an important pdf book and I want user can read only but can not share or redistribute it. Please give an idea. I will change my code.

I am using following code:

Uri path = Uri.fromFile(new File(str,
                "lemmelibroandroid.pdf")); 
Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
pdfIntent.setDataAndType(path, "application/pdf");
pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(pdfIntent);

Upvotes: 3

Views: 2579

Answers (2)

EvZ
EvZ

Reputation: 12179

It is not possible,so the best option here will be to show your content in your own app.
I am sure that you will find a proper way to display it some how in activity.
Maybe you should change the format of PDF to HTML and it will be easier to show.

Upvotes: 1

pretorh
pretorh

Reputation: 131

I dont think it is possible to limit the capabilities of the external application used to open the pdf

Have a look at http://asmncl.blogspot.in/2012/06/android-open-pdf-file-in-webview.html to see how to open the pdf in a WebView

Upvotes: 4

Related Questions