-
-
Save Arunshaik2001/385209b1440b9c66fb7c7d8c6207397d 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
fun createNotificationWithBackStack(context: Context){ | |
val resultIntent = Intent(context, MainActivity2::class.java) | |
val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(context).run { | |
addNextIntentWithParentStack(resultIntent) | |
getPendingIntent(0, | |
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE) | |
} | |
val builder = NotificationCompat.Builder(context, NotificationChannels.CHANNEL1) | |
.setSmallIcon(com.google.accompanist.permissions.R.drawable.notification_bg) | |
.setContentTitle("textTitle") | |
.setContentIntent(resultPendingIntent) | |
.setContentText("textContent") | |
.setPriority(NotificationCompat.PRIORITY_DEFAULT) | |
.setVisibility(VISIBILITY_SECRET) | |
.addAction( | |
R.drawable.ic_launcher_background, | |
"Click", | |
addAction(context, "click_action") | |
) | |
.addAction(replyAction(context)) | |
.setAutoCancel(true) | |
val notificationManagerCompat = NotificationManagerCompat.from(context) | |
notificationManagerCompat.notify(12345, builder.build()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment