Slide 39
Slide 39 text
Notification
trampoline
●
Android 12 restreint l’effet de
trampoline via les notifications
●
Interdiction d’ouvrir une Activity
depuis un Service ou un
BroadcastReceiver
// On crée notre notification avec notre Broadcast
val broadcastIntent = Intent(context,
NotificationReceiver::class.java)
val actionIntent = PendingIntent.getBroadcast(
context,
0,
broadcastIntent,
PendingIntent.FLAG_UPDATE_CURRENT or
PendingIntent.FLAG_IMMUTABLE
)
val notification = NotificationCompat.Builder(context,
CHANNEL_ID)
.setSmallIcon(R.drawable.icon)
.setContentTitle("Android12")
.setContentText("Notification trampoline")
.addAction(R.drawable.icon, "Open activity",
actionIntent)
.build()
notificationManager.notify(getUniqueId(), notification)
Indirect notification activity start (trampoline) from
PACKAGE_NAME, this should be avoided for performance
reasons.