I'm using Android Download Manager to download list of files. Lately I came across a crash report saying
Unknown java.lang.IllegalArgumentException: Unknown URL content://downloads/my_downloads
Then later, I figured it out that the reason is because user disabled Android Download Manager. I check if the Download Manager is disabled by checking it's package name with the code below.
int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads");
And now, I need to find a way to enable the Download Manager if it is disabled. I tried setting it's enable state with the permission in Manifest but I keep getting Security Exception.
this.getPackageManager().setApplicationEnabledSetting("com.android.providers.downloads", PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0); <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
So I thought it might not be reachable because of it is a system app. (Google Play App does it).
Is there any way to redirect the user to the Download Manager Application Info view ? to let the user enables it ? If there is no way to enable it on run time programmatically.
Select the Download Manager app. ? If an Enable option is shown, Download Manager is turned off. Touch Enable to turn it on.? If a Disable option is shown, Download Manager is turned on.
You can find your downloads on your Android device in your My Files app (called File Manager on some phones), which you can find in the device's App Drawer. Unlike iPhone, app downloads are not stored on the home screen of your Android device, and can be found with an upward swipe on the home screen.
Android Download Manager Not Working Sometimes the Android Download Manager doesn't work. Oftentimes, the files it's downloading (to a temporary location called a "cache") become corrupted. In this case, wiping the cache should fix the problem.
Please edit my answer if is not valid
Check if download manager is available:
int state = this.getPackageManager().getApplicationEnabledSetting("com.android.providers.downloads"); if(state==PackageManager.COMPONENT_ENABLED_STATE_DISABLED|| state==PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER ||state==PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED){ // Cannot download using download manager } else { request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName); request.setDescription(fileName); manager.enqueue(request); }
And the solution for trying to enable download manager is:
packageName = "com.android.providers.downloads" try { //Open the specific App Info page: Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + packageName)); startActivity(intent); } catch ( ActivityNotFoundException e ) { //e.printStackTrace(); //Open the generic Apps page: Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); startActivity(intent); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With