Specify FLAG_IMMUTABLE for pending intent

This commit is contained in:
Aleksandras Kostarevas 2024-01-17 15:55:30 +02:00
parent 9a358d27a7
commit 3b85a3f0ec
2 changed files with 2 additions and 2 deletions

View File

@ -230,7 +230,7 @@ public final class DictionaryService extends Service {
final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS); final long alarmTime = now + new Random().nextInt(MAX_ALARM_DELAY_MILLIS);
final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION); final Intent updateIntent = new Intent(DictionaryPackConstants.UPDATE_NOW_INTENT_ACTION);
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0,
updateIntent, PendingIntent.FLAG_CANCEL_CURRENT); updateIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
// We set the alarm in the type that doesn't forcefully wake the device // We set the alarm in the type that doesn't forcefully wake the device
// from sleep, but fires the next time the device actually wakes for any // from sleep, but fires the next time the device actually wakes for any

View File

@ -187,7 +187,7 @@ class TrainingWorker(context: Context, parameters: WorkerParameters) : Coroutine
val cancel = "Halt" val cancel = "Halt"
// This PendingIntent can be used to cancel the worker // This PendingIntent can be used to cancel the worker
val intent = WorkManager.getInstance(applicationContext) val intent = WorkManager.getInstance(applicationContext)
.createCancelPendingIntent(getId()) .createCancelPendingIntent(id)
// Create a Notification channel if necessary // Create a Notification channel if necessary
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {