HeadsUp通知未显示在KitKat上 [英] HeadsUp Notification not displayed on KitKat

查看:116
本文介绍了HeadsUp通知未显示在KitKat上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条通知,使用以下代码显示:

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);

在Lollypop及更高版本上运行时,它可以正常工作,并且该通知会同时显示在状态栏中和预期/期望的弹出通知中.在奇巧(Kitkat)上,通知仅显示在状态栏中,没有弹出通知.我仍然可以从状态栏打开通知,一切看起来和工作都很好,只是缺少了弹出通知.

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:

  • setDefaults
  • 的不同选项
  • setPriority
  • 的不同选项
  • 已验证该应用程序的系统设置面板中的通知已打开
  • different options to setDefaults
  • different options to setPriority
  • verified that notifications are on in the system settings panel for the application

推荐答案

在奇巧上,通知仅显示在状态栏中,没有弹出通知

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

这是因为抬头通知行为是在Android 5.0中添加的,并且在以前的Android版本中不存在.

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

这篇关于HeadsUp通知未显示在KitKat上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆