Я использую DownloadManager для загрузки файлов из веб-просмотра, и он работает почти во всех случаях, кроме MOTO G6 Play. Есть кто-нибудь, кто знает, как я могу заставить его работать?
Мой код:
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setMimeType(mimeType);
//------------------------COOKIE!!------------------------
String cookies = CookieManager.getInstance().getCookie(url);
request.addRequestHeader("cookie", cookies);
//------------------------COOKIE!!------------------------
request.addRequestHeader("User-Agent", userAgent);
request.setDescription(getString(R.string.download_start));
request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType));
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType));
DownloadManager dm = (DownloadManager) getContext().getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(request);
Я пытался поставить
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
Но не сработало