我目前升级适配Android12 目前遇到一个问题
AndroidRuntime: java.lang.RuntimeException: Unable to start service cn.leancloud.push.PushService@ec278aa with Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=/.ui.actuating.ActuatingActivity }: java.lang.IllegalArgumentException: : Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
然后将leancloud升级至8.2.5 去查看PushService发现onTaskRemoved该方法中
if (enableForegroundService && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(restartServiceIntent);
}else {
PendingIntent restartServicePendingIntent =
PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarmService =
(AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE);
alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 500,
restartServicePendingIntent);
}
因为没有调用setForegroundMode这个方法 所以 会一直进入else 你们调用 PendingIntent.FLAG_UPDATE_CURRENT 那岂不是还是会一直崩溃