Updated again: Suddenly the original code is working as expected. It seems most likely that rebooting the phone in the emulator fixed this issue.
I'm currently working through this WorkManager Codelab, using API 34-ext15
The solution code is here.
The codelab generates notifications in this piece of the code. All through the lab it talks about the notifications appearing as pop-ups, but they do not. They only appear in the notification bar, which has to be opened to view them. This makes it more difficult to follow the progress of the notifications as they occur (which is the goal of the notifications in this exercise). I'd prefer them to be pop-ups, and to know how to do/enable pop-up notifications in general.
Has something changed? I haven't found an app-specific permission that affects this. Is there a newer way to do pop-up notifications that the codelab hasn't been updated to use, or are pop-up notifications no longer permitted as of API 34
?
Here is the actual code:
fun makeStatusNotification(message: String, context: Context) {
// Make a channel if necessary
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
val name = VERBOSE_NOTIFICATION_CHANNEL_NAME
val description = VERBOSE_NOTIFICATION_CHANNEL_DESCRIPTION
val importance = NotificationManager.IMPORTANCE_HIGH
val channel = NotificationChannel(CHANNEL_ID, name, importance)
channel.description = description
// Add the channel
val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?
notificationManager?.createNotificationChannel(channel)
}
// Create the notification
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.drawable.ic_launcher_foreground)
.setContentTitle(NOTIFICATION_TITLE)
.setContentText(message)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setVibrate(LongArray(0))
// Show the notification
NotificationManagerCompat.from(context).notify(NOTIFICATION_ID, builder.build())
}
Here is the expected appearance:
Updated: Removed incorrect reference to Bubbles - the problem is with Heads-Up notifications