Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to download adobe reader programatically if not exists

Tags:

android

Now I am working on an application. Through my app users can read pdf files and if pdf reader is not there then my app automatically will install it from the site. This is the code I used for reading pdf file.

File file = new File("/sdcard/sample.pdf");
PackageManager packageManager = getPackageManager();
Intent testIntent = new Intent(Intent.ACTION_VIEW);
testIntent.setType("application/pdf");
List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() > 0 && file.isFile()) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    Uri uri = Uri.fromFile(file);
    intent.setDataAndType(uri, "application/pdf");
    startActivity(intent);
}

My doubts are:

  1. How to check there is a adobe reader installed in phone or not?
  2. How to programatically install the adobe reader on a phone?
like image 413
sarath Avatar asked Feb 28 '12 10:02

sarath


People also ask

Why can't I install Adobe Reader?

Try a different browser. Certain conditions on your computer, such as security settings or browser cookies, can prevent the Acrobat Reader Installer from downloading. Often, the easiest way to resolve an unsuccessful download is to try the download again using a different browser.

How do I install Adobe Reader offline?

Step 1: Proceed to Download Go to the download page of the official website of Adobe Reader Offline Installer and click 'Install now'. It will initialize the download process and then you will see a dialog box. You can choose to 'Save File' for further installation of the program.

How do I install Adobe Reader on my computer?

Close any browser that is displaying a PDF. Go to the Adobe Acrobat Reader download page and click Download Acrobat Reader. Click Save to download the Reader installer. When the downloaded file appears at the bottom of the browser window, click the .exe file for Reader.

Where is Acrobat Reader located?

To find out if you have Adobe Acrobat Reader installed on your computer, follow these steps: Click the Start button on your taskbar (usually found in the bottom left of the computer screen). Select All Programs from the pop-up menu. Verify that there is a folder called Adobe Acrobat listed.


2 Answers

From your code some complication..

Use this code,

Intent intent;
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(file, "application/pdf");
        try {
            startActivity(intent);
        } catch (ActivityNotFoundException e) {
            // No application to view, ask to download one
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle("No Application Found");
            builder.setMessage("Download one from Android Market?");
            builder.setPositiveButton("Yes, Please",
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Intent marketIntent = new Intent(Intent.ACTION_VIEW);
                            marketIntent
                                    .setData(Uri
                                            .parse("market://details?id=com.adobe.reader"));
                            startActivity(marketIntent);
                        }
                    });
            builder.setNegativeButton("No, Thanks", null);
            builder.create().show();
        }
    }
like image 86
user370305 Avatar answered Nov 15 '22 03:11

user370305


I think this may help you:

private void loadDocInReader(String doc) throws ActivityNotFoundException, Exception {

try {
    Intent intent = new Intent();

    intent.setPackage("com.adobe.reader");
    intent.setDataAndType(Uri.parse(doc), "application/pdf");

    startActivity(intent);

} 

catch (ActivityNotFoundException activityNotFoundException) {
            activityNotFoundException.printStackTrace();

            throw activityNotFoundException;
} 
catch (Exception otherException) {
            otherException.printStackTrace();

            throw otherException;
}
}

If the Adobe reader is not installed you can drag user to this url:

https://market.android.com/details?id=com.adobe.reader

This will open Adobe Reader in Android Market mobile App. If users want, they can install.

like image 40
Sadeshkumar Periyasamy Avatar answered Nov 15 '22 04:11

Sadeshkumar Periyasamy