0
からダウンロードした後、Pdf/.docファイルが壊れています。1)ダウンロードマネージャーからアンドロイドスタジオに.docx/pdfファイルをダウンロードした後、「ファイルに読み込めないコンテンツがあります。それを回復する?
2)しかし、私はjpgまたはmp3をダウンロードすると、正常に動作します。Androidスタジオでダウンロードマネージャ
マイコード:
private long DownloadData (Uri uri, View v) {
long downloadReference;
downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(uri);
//Setting title of request
request.setTitle("ZoraizCV");
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
//Setting description of request
request.setDescription("Android Data download using DownloadManager.");
//Set the local destination for the downloaded file to a path within the application's external files directory
if(v.getId() == R.id.DownloadMusic)
request.setDestinationInExternalFilesDir(MainActivity.this, Environment.DIRECTORY_DOWNLOADS,"zoraizCV.docx");
request.allowScanningByMediaScanner();
//Enqueue download and save the referenceId
downloadReference = downloadManager.enqueue(request);
Button DownloadStatus = (Button) findViewById(R.id.DownloadStatus);
DownloadStatus.setEnabled(true);
Button CancelDownload = (Button) findViewById(R.id.CancelDownload);
CancelDownload.setEnabled(true);
return downloadReference;
}