0

WebView で PDF ファイルのダウンロード イベントをインターセプトし、DownloadManager を使用してダウンロードし、Adobe Reader で新しいインテントを起動してファイルを表示する Android アプリがあります。Adobe Reader の起動時に、実際のファイルを表示する前に次のメッセージが表示されることを除いて、問題なく動作します。

読み取り専用ドキュメント | このドキュメントを変更するには、デバイスにコピーを保存してください。保存 | 読み取り専用で表示

このプロンプトを閉じると、ドキュメントが正しく表示されます。読み取り専用プロンプトを取り除くにはどうすればよいですか?

これが私のコードです:

public class MyDownloadListener implements DownloadListener {

    MainActivity activity;
    BroadcastReceiver receiver;
    DownloadManager downloadManager;

    public MyDownloadListener(MainActivity a) {
        activity = a;
        downloadManager = (DownloadManager) activity.getSystemService(Context.DOWNLOAD_SERVICE);
        receiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String action = intent.getAction();
                if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                    long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                    Query query = new Query();
                    query.setFilterById(downloadId);
                    Cursor c = downloadManager.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_FILENAME));
                            File fileSrc = new File(uriString);
                            Intent intentPdf = new Intent(Intent.ACTION_VIEW);
                            intentPdf.setDataAndType(Uri.fromFile(fileSrc), "application/pdf");
                            intentPdf.setPackage("com.adobe.reader");
                            intentPdf.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            activity.startActivity(intentPdf);
                        }
                    }
                }
            }
        };
        activity.registerReceiver(receiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    }

    @Override
    public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
        Request request = new Request(Uri.parse(url));
        downloadManager.enqueue(request);
    }
}
4

1 に答える 1