我在我的
android项目中使用DownloadManager来下载文件.
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(soundURL)); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN); deleteIfFileExist(filePath); request.setDestinationInExternalFilesDir(context,SubPath,SndName); return manager.enqueue(request);
它工作正常,但我在Fabric中看到一些用户报告崩溃:
Fatal Exception: java.lang.IllegalArgumentException: UnkNown URL content://downloads/my_downloads at android.content.ContentResolver.insert(ContentResolver.java:882) at android.app.DownloadManager.enqueue(DownloadManager.java:904)
我搜索了它并找到了某处因为他们的Downloadmanger被禁用了.但我在Android设备上看到Android版本是4,他们没有能力禁用它.任何人都可以帮助我为什么会发生这种错误?
解决方法
无法直接激活/停用Download Manager,因为它是系统应用程序,我们无法访问它.
try { //Open the specific App Info page: Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + "com.android.providers.downloads")); 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); }