【发布时间】:2022-04-07 17:10:36
【问题描述】:
定位 S+(版本 31 及更高版本)要求在创建 PendingIntent 时指定 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一。强烈考虑使用 FLAG_IMMUTABLE,仅当某些功能依赖于 PendingIntent 可变时才使用 FLAG_MUTABLE
我无法在 android studio 项目编码中更新待定意图标志
这是AlarmPingSender.java中发生错误的地方
public void start()
{
String action = MqttServiceConstants.PING_SENDER
+ comms.getClient().getClientId();
Log.d(TAG, "Register alarmreceiver to MqttService"+ action);
service.registerReceiver(alarmReceiver, new IntentFilter(action));
pendingIntent = PendingIntent.getBroadcast(service, 0, new Intent(
action), PendingIntent.FLAG_UPDATE_CURRENT);
schedule(comms.getKeepAlive());
hasStarted = true;
}
【问题讨论】:
-
欢迎来到 Stackoverflow!请编辑您的问题并添加创建
PendingIntent的代码。 -
请大家帮忙
-
错误信息告诉你应该做什么。 Stackoverflow 上也有很多问题涵盖了这个确切的问题。见developer.android.com/guide/components/…
-
我不知道在哪里更改代码的待定意图,我们尝试了很多方法和代码中的各个位置,但它不起作用
标签: android android-studio android-pendingintent