相关疑难解决方法(0)

如何解决android api 30+中的“缺少PendingIntent可变性标志”lint警告?

只要我的目标更新SDK30(安卓R),棉绒警告Missing PendingIntent mutability flag出现在我的PendingIntent.FLAG_UPDATE_CURRENT标志时,我想定义PendingIntent

我应该如何处理这个 lint 而不影响应用程序功能?

android lint android-pendingintent

26
推荐指数
12
解决办法
6141
查看次数

Android paho mqtt 导致 Android 12 崩溃 - 定位 S+(版本 31 及更高版本)需要 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

我正在使用 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' 作为 mqtt 服务,并且该应用程序在 Android 12 设备上不断崩溃,并显示以下崩溃日志

java.lang.IllegalArgumentException: app id: 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 needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
        at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:76)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1214)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:1050)
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:151)
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的库:

implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Run Code Online (Sandbox Code Playgroud)

java kotlin android-pendingintent paho android-12

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

android-pendingintent ×2

android ×1

android-12 ×1

java ×1

kotlin ×1

lint ×1

paho ×1