1
votes

I'm trying to open a pdf file from a server in adobe reader. These are valid pdfs that I can view in other apps. The following code gives me a message saying "The document could not be opened" Any ideas why?

    PackageManager pm = getPackageManager();
    Intent intent = pm.getLaunchIntentForPackage("com.adobe.reader");
    intent.setDataAndType(Uri.parse(documents.get(position).getPdf_url()), "application/pdf");
    startActivity(intent);
2
Can the Adobe Reader app display documents from URL's without downloading them first?Lukas Knuth
Agreed, usually PDF viewers are working with local files. Also, please allow the user to choose their PDF viewer.CommonsWare
can you refer me to an explanation of how to download the pdf to local storage?androiddev19
You can use the DownloadManagerLukas Knuth

2 Answers

0
votes
            Intent intent = new Intent();
            intent.setPackage("com.adobe.reader");
            intent.setDataAndType(Uri.parse(doc), "application/pdf");
            startActivity(intent);

Above code is working for me, There are two possibilities, may be you need to set package with intent only or you are doing something wrong with doc URI.

0
votes

The solution was to download the pdf files to local memory before opening in an external app.