小编Jos*_*aya的帖子

针对 S+(版本 31 及更高版本)要求在创建 PendingIntent、On AlarmPingSender 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

问题

面向 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。我在将目标 SDK 更新到 31 后得到它。错误总是出现在 AlarmPingSender 之后。但我不知道任何使用 AlarmPingSender 的类。


2021-10-31 10:43:04.990 17031-17341/com.app.mobile D/AlarmPingSender: Register alarmreceiver to MqttServiceMqttService.pingSender.com.app.mobile-2e24ccbde048f2e91635651784
2021-10-31 10:43:04.993 17031-17341/com.app.mobile E/AndroidRuntime: FATAL EXCEPTION: MQTT Rec: com.app.mobile-2e24ccbde048f2e91635651784
    Process: com.app.mobile, PID: 17031
    java.lang.IllegalArgumentException: com.app.mobile: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-pendingintent android-workmanager android-12

57
推荐指数
4
解决办法
7万
查看次数