lundi 25 juillet 2016

DownloadManager fails with ERROR_UNKNOWN on API 17

I'm trying to use android's own DownloadManager and it works perfectly on API 19+ but the same code fails (STATUS_FAILED) with reason ERROR_UNKNOWN almost as soon as I enqueue it on API 17 phones. here's my code

Context context = MyApplication.getSharedContext();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE).setTitle(notiTitle).
setVisibleInDownloadsUi(false);
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+fileName);
request.setDestinationUri(Uri.fromFile(file));
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
manager.enqueue(request);

Aucun commentaire:

Enregistrer un commentaire