Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reliably detect PDF support on Android device

Tags:

android

pdf

I am using a method to detect pdf support on an Android device that goes like this

public boolean canDisplayPdf() {
    PackageManager packageManager = application.getPackageManager();
    Intent testIntent = new Intent(Intent.ACTION_VIEW);
    testIntent.setType("application/pdf");
    if (packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
        return true;
    } else {
        return false;
    }
}

And that has been working great so far. I know that at least the HTC default viewer, droidreader and adobe acrobat get reported that way and the right result is returned. However I now got a comment on the market console by a user that says that he has pdf support on the device, but from the described behaviour of the app I conclude that this method returns false.

Is there any better way to detect pdf support?

PS: I would love to be able to ask the user for details on the market.

like image 629
Manfred Moser Avatar asked Feb 04 '11 17:02

Manfred Moser


People also ask

Do Android phones have a PDF reader?

Open and read PDFs on Android. Launch the app. On the bottom menu bar, select Files. Locate your PDF file on your Android and select it. Read your document.

How do I set default PDF viewer on Android?

Go to Settings. Go to Apps. Select the other PDF app, that always open up automatically. Scroll down to "Launch By Default" or "Open by default".

Does Android have native PDF viewer?

Android has a built in framework from Android 5.0 / Lollipop, it's called PDFRenderer.


2 Answers

From all sources I found and practical experience testing on a rather large variety of devices the approach I have taken is correct.

I have not had any further feedback and think there might have been user error or a bad pdf application version involved.

like image 106
Manfred Moser Avatar answered Oct 17 '22 08:10

Manfred Moser


You're doing it correctly. You could consider updating the description of your app to say that you invoke a PDF app using the Android-approved method with the application/pdf MIME type. And also mention that if users have any trouble with the app, you'd appreciate an email to [email protected] (or whatever your app support email address is setup to be). Maybe then they'd send an email instead of just leaving an anonymous comment.

like image 2
Dave MacLean Avatar answered Oct 17 '22 07:10

Dave MacLean