首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓13中未显示DownloadManager通知

安卓13中未显示DownloadManager通知
EN

Stack Overflow用户
提问于 2022-08-25 02:52:11
回答 2查看 231关注 0票数 0
代码语言:javascript
复制
  val downloadManager = getSystemService(DOWNLOAD_SERVICE) as DownloadManager
            val request = DownloadManager.Request(Uri.parse("https://xxx.xx"))
            val filename = "update" + System.currentTimeMillis()
            val dir: String = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).toString() + "/"
            val file = File("$dir$filename.apk")
            request.setTitle("dm-test")
            request.setDescription("downing...")
            request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
            request.setMimeType("application/vnd.android.package-archive")
            request.setDestinationUri(Uri.fromFile(file))
            downloadManager.enqueue(request)

此代码在android api<33中工作没有问题,在android api=33通知中没有工作。

EN

回答 2

Stack Overflow用户

发布于 2022-09-13 05:41:03

你可以试一次

Request.setVisibleInDownloadsUi(真);

也许它能起作用

票数 0
EN

Stack Overflow用户

发布于 2022-11-24 12:25:27

如果您的应用程序目标操作系统是android 13,则需要向用户请求通知权限。

你可以参考下面的链接,

https://developer.android.com/develop/ui/views/notifications/notification-permission

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73481383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档