0

我在 android oreo 上下载和可视化 PDF 时遇到问题。代码,下载pdf(在通知中显示加载器)。下载完成后,播客打开选择器,但是当我选择 Adob​​e Reader 或另一个时,它说我:“它无法访问此文件。检查路径或网络”。我错了什么?

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) {
                    }
                }
            }
        }
    }
};
4

0 回答 0