I'm trying to make persistent heads-up notifications with full-screen intent same as the Messenger app.
Messenger behavior:
- An app is showing: show heads-up
- At home screen, not showing any app and not locked: show heads-up
- When locked: show full-screen intent
My behavior:
- An app is showing: show heads-up
- At home screen, not showing any app and not locked: show full-screen intent
- When locked: show full-screen intent
My code:
val notificationBuilder: NotificationCompat.Builder = NotificationCompat.Builder(context, "my_channel_id")
.setSmallIcon(R.drawable.ic_video)
.setContentTitle("Full Screen Notification")
.setContentText("Notification Content Text")
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setFullScreenIntent(getActivityPendingIntent(notificationId, data), true)
val notificationManager = NotificationManagerCompat.from(context)
notificationManager.notify(12345, notificationBuilder.build())
How to show heads-up notifications instead of full-screen intent at home screen like Messenger?
Reference: setFullScreenIntent