Merge pull request #2380 from organicmaps/rt-android-fix-pendingintent

[android] Add missing PendingIntent.FLAG_IMMUTABLE flag

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2022-04-11 18:19:06 +03:00 committed by GitHub
parent c0a73aea48
commit d2bfde1558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,6 +6,7 @@ import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
@ -50,8 +51,9 @@ public final class Notifier
Intent intent = MwmActivity.createShowMapIntent(mContext, id)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
final int flags = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, flags);
String channel = NotificationChannelFactory.createProvider(mContext).getDownloadingChannel();
placeNotification(title, content, pi, ID_DOWNLOAD_FAILED, channel);