0

I have a problem with download and visualize PDF on android oreo. The code, download the pdf (in notification show the loader). Whe the download is complete the boradcast open the chooser, but when I select Adobe Reader or anothe , it say me:"It can not access to this file. Check the path or the network". What I wrong?

String url = "https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf"
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
enqueue = dm.enqueue(request);

BroadcastReceiver receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
            DownloadManager.Query query = new DownloadManager.Query();
            query.setFilterById(enqueue);
            Cursor c = dm.query(query);
            if (c.moveToFirst()) {
                int columnIndex = c
                        .getColumnIndex(DownloadManager.COLUMN_STATUS);
                if (DownloadManager.STATUS_SUCCESSFUL == c
                        .getInt(columnIndex)) {
                    String uriString = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
                    try {
                        Intent intent1 = new Intent();
                        //intent1.setPackage("com.adobe.reader");
                        intent1.setDataAndType(Uri.parse(uriString), "application/pdf");
                        Intent chooserIntent = Intent.createChooser(intent1, "Apri il pdf con:");
                        startActivity(chooserIntent);
                    } catch (ActivityNotFoundException activityNotFoundException) {
                    }
                }
            }
        }
    }
};
Gowthaman M
  • 8,057
  • 8
  • 35
  • 54
Pab
  • 3
  • 9

0 Answers0