alan yang
alan yang

Reputation: 39

How to use downloadmanager on Huawei?

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

Answers (1)

alan yang
alan yang

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

Related Questions