Home > Tricks & Tips > Check whether droid can handle PDF file

Check whether droid can handle PDF file


A cool snippet for today:

    public boolean canReadPdf(Context c) {
    	PackageManager pm = c.getPackageManager();
    	Intent data = new Intent(Intent.ACTION_VIEW);
    	// set MIME type
    	data.setType("application/pdf");
    	// if any package being able to handle PDF file
    	if(pm.queryIntentActivities(data, PackageManager.MATCH_DEFAULT_ONLY).size() > 0) {
    		return true;
    	}
    	// not found any
    	return false;
    }

Hope you like it!

Cheers,
Pete Houston

Advertisements
Categories: Tricks & Tips Tags: , , , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: