Answer the question
In order to leave comments, you need to log in
Why is the file not downloading in Android using DownloadManager?
Here is the code:
try {
DownloadManager dm;
dm = (DownloadManager)getApplicationContext().getSystemService(DOWNLOAD_SERVICE);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(DOWNLOAD_URL));
request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI | DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle("Download")
.setDestinationInExternalPublicDir(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
,"file.jpg");
Log.d("DEBUG", Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() );
dm.enqueue(request);
}catch (Exception e){
Toast.makeText(this, "Error", Toast.LENGTH_LONG).show();
}
E/ActivityThread: Service com.android.providers.downloads.DownloadJobService has leaked IntentReceiver com.android.pr[email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Service com.android.providers.downloads.DownloadJobService has leaked IntentReceiver [email protected] that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1355)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1134)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1421)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1394)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1382)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:609)
at addon.sprd.downloadprovider.AddonDownloadsDRMUtils.notifyDownloadCompleted(AddonDownloadsDRMUtils.java:302)
at com.android.providers.downloads.DownloadThread.run(DownloadThread.java:504)
Answer the question
In order to leave comments, you need to log in
More than 10 hours killed to find and solve the problem. It turned out to be - Are you missing a call to unregisterReceiver()? generally does not relate to the problem in any way. The problem was the presence of the ad blocker Blokada (works as a local vpn server). And what is most interesting, Blokada shows all the hosts that Android and other applications access (assuming the application accesses http/https), even if they are on the block list. But when I started my application, she just kept silent. Probably a blocker bug.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question