android - 在下载管理器通知中显示下载速度
问题描述
Q1。我是安卓新手。我正在尝试开发一个使用下载管理器的应用程序。我想显示连接的下载速度(移动/Wifi,无论用户连接和下载的连接)。我不知道如何实现这一点。
Q2。下载管理器没有通过本地地址(如 192.168)下载是否有任何问题。. /file_name.extn? 只有当数据打开时才会出现下载通知,但下载并不总是失败。服务器工作正常,在浏览器上工作。
我使用的代码:
String url =mainActivity_downloadLink.getText().toString();
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
//request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE | DownloadManager.Request.NETWORK_WIFI);
request.setTitle("Testing ");
request.setDescription("the file is downloading");
request.allowScanningByMediaScanner();
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
, request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_DOWNLOADS,""+System.currentTimeMillis());
//request.setDestinationInExternalFilesDir(MainActivity.this,Environment.DIRECTORY_DOWNLOADS,URLUtil.guessFileName(url, contentDisposition, mimeType));
DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
downloadManager.enqueue(request);
}
任何帮助提前感谢。
解决方案
推荐阅读
- java - 有没有办法使用 intellj 为我的 java 测试使用额外的测试数据库?
- c# - 我似乎无法找到我试图在 c# 中修复的这段代码背后的错误,它使用了几个由主题标签符号分隔的类
- mysql - 使用 Postman 插入数据会导致 MySQL 中的值未定义,使用 Lambda 插入不会(行正常)
- c# - CS1061:“变换”不包含“LocalScale”的定义
- exoplayer - 使用 ImageReader 时无法初始化解码器,但可以直接播放
- android - Xamarin Android:如何在 Android 11 中设置 SystemUiFlags
- c++ - 背包实现未正确填充。已经尝试调试好几天了。还在学习
- javascript - 节点 Js Puppeteer 值未在函数中定义(page.evaluate)
- javascript - 即使在链接后css也不会应用于nodejs
- blazor-webassembly - 我似乎无法让 DateTime.Now 在 Blazor 中工作?