このリンクからmp3ファイルをダウンロードできませんhttp://31.186.48.72/media/audio/a_209353.mp3 このリンクからダウンロードできます https://www.androidtutorialpoint.com/wp-content/uploads/2016/09/AndroidDownloadManager.mp3 android.app.DownloadManagerを使用してください。ここでDownloadManagerのダウンロードに失敗しました
Uri uri = Uri.parse(DOWNLOAD_FILE);
Log.d("download", "downloading....");
DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
String fileName = "testmp3";
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setTitle(fileName);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.allowScanningByMediaScanner();
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS,"test.mp3");
downloadManager.enqueue(request);
は、カーソル結果
_id=8
local_filename=null
mediaprovider_uri=null
destination=4
title=testmp3
description=
uri=http://31.186.48.72/media/audio/a_209353.mp3
status=403
hint=file:///mnt/sdcard/Download/test.mp3
media_type=null
total_size=-1
last_modified_timestamp=1511346244441
bytes_so_far=0
local_uri=null
reason=placeholder
失敗403エラー – Bek
なぜこのエラーが出るのかわかりません。しかし、私はブラウザを使ってダウンロードすることができます。リンクが機能しています。 – Bek
添付カーソルダンプ結果 – Bek