下载Manger不在Android Pie 9.0中工作(小米mi A2)

下载Manger不在Android Pie 9.0中工作(小米mi A2),第1张

概述在将设备 *** 作系统更新到 Android 9.0时,之前此代码工作正常(小米mi A2).现在,Android Pie 9.0上没有下载文件. 此外,它在Oreo,Nougat,Marshmallow工作正常 这是代码片段: File myDir = new File(Environment.getExternalStorageDirectory(), "MyApp"); if (! 在将设备 *** 作系统更新到 Android 9.0时,之前此代码工作正常(小米mi A2).现在,AndroID PIE 9.0上没有下载文件.

此外,它在Oreo,Nougat,Marshmallow工作正常

这是代码片段:

file myDir = new file(Environment.getExternalStorageDirectory(),"MyApp");        if (!myDir.exists()) {            myDir.mkdirs();        }        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",Locale.getDefault()).format(new Date());        DownloadManager mgr = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);        Uri downloadUri = Uri.parse(url);        DownloadManager.Request request = new DownloadManager.Request(                downloadUri);        request.setAllowednetworkTypes(                DownloadManager.Request.NETWORK_WIFI                        | DownloadManager.Request.NETWORK_MOBILE).setAllowedOverMetered(true)                .setAllowedOverRoaming(true).setTitle("Downloading demo file").                setVisibleInDownloadsUi(true)                .setDestinationInExternalPublicDir(folder_main + "/",timeStamp);        mgr.enqueue(request);

logcat中的错误:

11-27 11:17:28.056 4062-2814/? D/DownloadManager: [3970] Starting11-27 11:17:28.067 4062-2814/? W/DownloadManager: [3970] Stop requested with status http_DATA_ERROR11-27 11:17:28.068 4062-2814/? D/DownloadManager: [3970] Finished with status WAITING_TO_RETRY11-27 11:18:06.466 4062-2843/? D/DownloadManager: [3970] Starting11-27 11:18:06.576 4062-2843/? W/DownloadManager: [3970] Stop requested with status http_DATA_ERROR11-27 11:18:06.577 4062-2843/? D/DownloadManager: [3970] Finished with status WAITING_TO_RETRY11-27 11:19:06.581 4062-2867/? D/DownloadManager: [3968] Starting11-27 11:19:06.737 4062-2867/? W/DownloadManager: [3968] Stop requested with status http_DATA_ERROR11-27 11:19:06.738 4062-2867/? D/DownloadManager: [3968] Finished with status WAITING_TO_RETRY11-27 11:19:19.131 4062-2869/? D/DownloadManager: [3970] Starting11-27 11:19:19.144 4062-2869/? W/DownloadManager: [3970] Stop requested with status http_DATA_ERROR11-27 11:19:19.144 4062-2869/? D/DownloadManager: [3970] Finished with status WAITING_TO_RETRY11-27 11:19:36.243 4062-2872/? D/DownloadManager: [3969] Starting11-27 11:19:36.259 4062-2872/? W/DownloadManager: [3969] Stop requested with status http_DATA_ER

任何帮助,将不胜感激.谢谢

解决方法 这对我有用.经过小米mi A2今天收到软件更新通知.

什么对我有用

在应用程序标记中添加androID:networkSecurityConfig =“@ xml / network_security_config”

<application        androID:name=".ApplicationClass"        androID:allowBackup="true"        androID:harDWareAccelerated="false"        androID:icon="@mipmap/ic_launcher"        androID:label="@string/app_name"        androID:largeHeap="true"        androID:networkSecurityConfig="@xml/network_security_config"        androID:supportsRtl="true"        androID:theme="@style/Apptheme">

其中network_security_config.xml

<?xml version="1.0" enCoding="utf-8"?><network-security-config>    <base-config cleartextTrafficPermitted="true" /></network-security-config>

在res目录下创建XML,然后在xml文件夹中创建network_security_config.xml,如下图所示

This explains the issue in software

总结

以上是内存溢出为你收集整理的下载Manger不在Android Pie 9.0中工作(小米mi A2)全部内容,希望文章能够帮你解决下载Manger不在Android Pie 9.0中工作(小米mi A2)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1121469.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存