Skip to content

Commit

Permalink
Use immutable pending intent flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KamWithK committed Mar 15, 2022
1 parent 503f621 commit dfcfb21
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ public void onCreate() { // Only one time
public int onStartCommand(Intent intent, int flags, int startId) { // Every time start is called
Log.w("onStartCommand", "onStartCommand");
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
} else {
pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}

Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Ankiconnect Android")
Expand Down

0 comments on commit dfcfb21

Please sign in to comment.