gpt4 book ai didi

安卓下载管理器错误

转载 作者:行者123 更新时间:2023-11-30 04:12:45 25 4
gpt4 key购买 nike

我正在尝试以这种方式使用 Android DownloadManager 类: super.onCreate(savedInstanceState); setContentView(R.layout.main);

Request r = new Request(Uri.parse("http://url"));
r.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, "file.ext"); // also tried all other possible ways to set up destination
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
dm.enqueue(r);

在最后一行,dm.enqueue(r) 应用程序崩溃了。日志错误:

05-12 13:53:55.408: E/JavaBinder(6814): *** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
05-12 13:53:55.408: E/JavaBinder(6814): java.lang.NoSuchMethodError: getExternalStorages
05-12 13:53:55.408: E/JavaBinder(6814): at com.android.providers.downloads.Helpers.isFilenameValid(Helpers.java:652)
05-12 13:53:55.408: E/JavaBinder(6814): at com.android.providers.downloads.DownloadProvider.checkFileUriDestination(DownloadProvider.java:613)
05-12 13:53:55.408: E/JavaBinder(6814): at com.android.providers.downloads.DownloadProvider.insert(DownloadProvider.java:500)
05-12 13:53:55.408: E/JavaBinder(6814): at android.content.ContentProvider$Transport.insert(ContentProvider.java:198)
05-12 13:53:55.408: E/JavaBinder(6814): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
05-12 13:53:55.408: E/JavaBinder(6814): at android.os.Binder.execTransact(Binder.java:324)
05-12 13:53:55.408: E/JavaBinder(6814): at dalvik.system.NativeStart.run(Native Method)
05-12 13:53:55.408: W/dalvikvm(6814): threadid=7: thread exiting with uncaught exception (group=0x2aac8620)
05-12 13:53:55.408: E/AndroidRuntime(6814): FATAL EXCEPTION: Binder Thread #1
05-12 13:53:55.408: E/AndroidRuntime(6814): java.lang.NoSuchMethodError: getExternalStorages
05-12 13:53:55.408: E/AndroidRuntime(6814): at com.android.providers.downloads.Helpers.isFilenameValid(Helpers.java:652)
05-12 13:53:55.408: E/AndroidRuntime(6814): at com.android.providers.downloads.DownloadProvider.checkFileUriDestination(DownloadProvider.java:613)
05-12 13:53:55.408: E/AndroidRuntime(6814): at com.android.providers.downloads.DownloadProvider.insert(DownloadProvider.java:500)
05-12 13:53:55.408: E/AndroidRuntime(6814): at android.content.ContentProvider$Transport.insert(ContentProvider.java:198)
05-12 13:53:55.408: E/AndroidRuntime(6814): at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:146)
05-12 13:53:55.408: E/AndroidRuntime(6814): at android.os.Binder.execTransact(Binder.java:324)
05-12 13:53:55.408: E/AndroidRuntime(6814): at dalvik.system.NativeStart.run(Native Method)

但如果我不以任何方式指定目的地,文件就会成功下载。

我完全不明白这是什么问题。你能帮帮我吗?

最佳答案

在模拟器(或其他一些未修改的环境)上尝试您的代码。您也可以考虑尝试使用已知的 working code .

关于安卓下载管理器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10562702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com