Last active
October 22, 2021 02:02
-
-
Save navczydev/5210681ad12d49ccd47ce4f04d6d66f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val broadcastIntent = Intent(context.applicationContext, NotificationReceiver::class.java) | |
val actionIntent = PendingIntent.getBroadcast( | |
context.applicationContext, | |
0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT or | |
// mutability flag required when targeting Android12 or higher | |
PendingIntent.FLAG_IMMUTABLE | |
) | |
// notification code | |
val notification = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID) | |
.setSmallIcon(R.mipmap.ic_launcher) | |
.setContentTitle("Android12") | |
.setContentText("Notification trampoline restrictions") | |
.addAction(R.mipmap.ic_launcher, "Open activity from receiver", actionIntent) | |
.setAutoCancel(true) | |
.build() | |
notificationManager.notify(getUniqueId(), notification) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment