Share Coding

Tutorials, Problems, Stuffs …

Open PDF file at Inent

// Check if file download state = complete && file exists
if (property.isTutorDLComplete() && tutorFile.exists()) {
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(tutorFile), "application/pdf");
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);
    } catch (ActivityNotFoundException activityNotFoundException) {
        // Error occur when there are no pdf reader
        activityNotFoundException.printStackTrace();
        // Ask for download PDF Reader
        showSimpleConfirmDialog(R.string.ask_dl_pdfreader, ACTION_DL_PDF_READER);
    }
} else {
    showSimpleAlertDialog(R.string.error_tutor);
}
// After confirm dialog, this function will be executed
private void goToDLPDFReader(){
    // Download adobe reader
    String url = "https://play.google.com/store/apps/details?id=com.adobe.reader";
    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    i.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(i);
}
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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: