\n\n
String serviceString = Context.DOWNLOAD_SERVICE;\n DownloadManager downloadManager;\n downloadManager = (DownloadManager) \n getSystemService(serviceString);\n\n downloadStatus[id] = 1;\n\n Uri uri = Uri.parse(href);\n DownloadManager.Request request = new DownloadManager.Request(uri);\n request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);\n // request.setDestinationUri(Uri.parse(\"file://Download/\"+title));\n\n // request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, title);\n\n long reference = downloadManager.enqueue(request);\n\n downloadRefs[id] = reference;\n downLoadRefToID.put(reference, id);\n
\n\n```
\n","author":{"@type":"Person","name":"alan yang"},"upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Well, I try to do some research on my own. Unfortunately, it seems like Huawei do something on DownloadManager Class such that we can't use it in a normal way. Thank you for all who volunteer to help.
\n\nFor quick reference, I finally solved the problem by using native JAVA rather than the DownloadManager Class.
\n","author":{"@type":"Person","name":"alan yang"},"upvoteCount":1}}}Reputation: 39
Thanks for all who see the problems. I am working on develop apps on android phone, my mobile phone is HUAWEI MATE8(android 7.0), I try to use downloadmanager to download some files in app. However, even if I give the full access to app,I can only see that all files to be downloaded keep the status"in queue", but none of them start to download.
I tried my app on virtual machine and on Xiaomi, and there is no such problem.
my code here:
String serviceString = Context.DOWNLOAD_SERVICE;
DownloadManager downloadManager;
downloadManager = (DownloadManager)
getSystemService(serviceString);
downloadStatus[id] = 1;
Uri uri = Uri.parse(href);
DownloadManager.Request request = new DownloadManager.Request(uri);
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
// request.setDestinationUri(Uri.parse("file://Download/"+title));
// request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, title);
long reference = downloadManager.enqueue(request);
downloadRefs[id] = reference;
downLoadRefToID.put(reference, id);
```
Upvotes: 1
Views: 2428
Reputation: 39
Well, I try to do some research on my own. Unfortunately, it seems like Huawei do something on DownloadManager Class such that we can't use it in a normal way. Thank you for all who volunteer to help.
For quick reference, I finally solved the problem by using native JAVA rather than the DownloadManager Class.
Upvotes: 1