-
-
Save Arunshaik2001/d19a4b4cc542dee0cb105899a5af23da 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 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