Skip to content

Commit 014fd0d

Browse files
authored
Merge pull request Tencent#995 from imndx/master
兼容Android 12
2 parents 0fdc1ca + 1c4bacf commit 014fd0d

File tree

1 file changed

+6
-1
lines changed
  • mars/libraries/mars_android_sdk/src/main/java/com/tencent/mars/comm

1 file changed

+6
-1
lines changed

mars/libraries/mars_android_sdk/src/main/java/com/tencent/mars/comm/Alarm.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ private static PendingIntent setAlarmMgr(final long id, final long time, final C
150150
intent.setAction("ALARM_ACTION(" + String.valueOf(Process.myPid()) + ")");
151151
intent.putExtra(KEXTRA_ID, id);
152152
intent.putExtra(KEXTRA_PID, Process.myPid());
153-
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, (int) id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
153+
PendingIntent pendingIntent;
154+
if (Build.VERSION.SDK_INT < 23) {
155+
pendingIntent = PendingIntent.getBroadcast(context, (int) id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
156+
} else {
157+
pendingIntent = PendingIntent.getBroadcast(context, (int) id, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
158+
}
154159

155160

156161
if (Build.VERSION.SDK_INT < 19) { //KITKAT

0 commit comments

Comments
 (0)