1

I have a notification, presented using the following code:

    // Create the notification
    android.app.Notification systemNotification = new NotificationCompat.Builder(context)
            // Set notification data and appearance
            .setContentTitle(notification.getNotificationLabel())
            .setContentText(notification.getMessage())
            .setSmallIcon(notification.getNotificationDrawable())
            .setWhen(new Date().getTime())

            // Set notification options
            .setCategory(NotificationCompat.CATEGORY_MESSAGE)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setDefaults(NotificationCompat.DEFAULT_ALL)
            .build()
    ;

    NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    notificationManager.notify(notification.getNotificationId(), systemNotification);

When run on Lollypop and newer, it works fine and the notification appears both in the status bar and as a popup notification as expected/desired. On Kitkat, the notification only appears in the status bar, there's no popup notification. I can still open the notification from the status bar and everything looks and works fine, it's just the popup notification that's missing.

Some of the things I've tried so far:

  • different options to setDefaults
  • different options to setPriority
  • verified that notifications are on in the system settings panel for the application
David Berry
  • 40,941
  • 12
  • 84
  • 95

2 Answers2

3

On Kitkat, the notification only appears in the status bar, there's no popup notification

That is because the heads-up notification behavior was added in Android 5.0 and did not exist in prior versions of Android.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Ensure that you have popup notifications enabled on your KitKat device.

shilch
  • 1,435
  • 10
  • 17