我的Android应用程序通知在Android 12上没有工作

发布于 2025-02-05 11:50:46 字数 523 浏览 2 评论 0原文

我正在尝试使用Workmanager和Kotlin中的频道显示通知。他们在具有较旧的Android的设备上工作正常,我已经在Android 8和Android 11上进行了测试。

但是,当我在Android 12设备(Realme 8)上尝试它们时,他们拒绝出现。我已经尝试更改通知优先级,检查设备上是否允许通知,调整通知量,没有任何帮助。我还使用Android 12和Android Emulator版本的Pixel XL在不同的Realme 8设备上对其进行了测试,该版本也是Android 12,它们在这些设备上也无法使用

其他应用程序的通知。只有我的应用程序在Android 12个设备上不起作用 ”在此处输入图像描述”

如果需要更多信息,请说。谢谢你的宝贵时间。

I am trying to display notification using WorkManager and Channels in Kotlin. They are working totally fine on devices with older Androids, I've tested it on Android 8 and Android 11.

But as I try them on Android 12 device (Realme 8) they refuse to show up. I've already tried to change Notification priority, check if the notifications are allowed on my device, tune up the notification volume, nothing helps. I also tested it on different Realme 8 device with Android 12 and also Android emulator version of Pixel XL which is also Android 12 and they didn't work on these devices as well

Other app's notifications work correctly. Only my App's doesn't work on the Android 12 devicesenter image description here.

If any more info needed, just say. Thank you for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぶ宁プ宁ぶ 2025-02-12 11:50:46

正如Vincent091所评论的那样...

解决方案对于此问题,以下是:

声明给定的pendingIntent对象是可变的或不可变的,请使用pendend> pendingIntent.flag_mutable 或pendingIntent.flag_immutable标志。

PendingIntent.getActivity(requireContext(), 0, Intent(), PendingIntent.FLAG_MUTABLE)

As vincent091 commented...

The SOLUTION for this problem is this:

To declare that a given PendingIntent object is mutable or immutable, use the PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_IMMUTABLE flag, respectively.

PendingIntent.getActivity(requireContext(), 0, Intent(), PendingIntent.FLAG_MUTABLE)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文