Skip to content

Instantly share code, notes, and snippets.

@Arunshaik2001
Created November 21, 2022 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arunshaik2001/d19a4b4cc542dee0cb105899a5af23da to your computer and use it in GitHub Desktop.
Save Arunshaik2001/d19a4b4cc542dee0cb105899a5af23da to your computer and use it in GitHub Desktop.
fun createNotificationWithSpecialActivity(context: Context){
val notifyIntent = Intent(context, MainActivity2::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val notifyPendingIntent = PendingIntent.getActivity(
context, 0, notifyIntent,
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(notifyPendingIntent)
.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)
with(NotificationManagerCompat.from(context)) {
notify(123456, builder.build())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment