notifications - 通知 android 5。状态栏图标为空,大图标上通知图标为空

标签 notifications android-5.0-lollipop

我在我的应用程序中使用通知。目前,我面临着显示 Android L 图标的问题。对于 4.4 及以下版本的设备,一切都很好。我使用的图标大小:大 - 图标 64 dp,图标状态栏 - 24 dp。设备 android L 图标状态栏显示为缺失的白色方 block :

enter image description here

在大图标上的通知上出现了空图标:

enter image description here

我想通知我的 Android 我看起来像这样:

enter image description here

Android L 上的状态栏图标将可见。 我的代码:

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                    .setSmallIcon(R.drawable.icon_notification_small)
                    .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.icon_notification);)
                    .setContentTitle(title)
                    .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS)
                    .setStyle(new NotificationCompat.BigTextStyle().bigText(content))
                    .setPriority(2)
                    .setAutoCancel(true)
                    .setTicker(ticker)
                    .setContentText(content);

最佳答案

对于您提供的示例,他们正在调用:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.icon_notification_small)
                .setColor(resources.getColor(R.color.icon_notification_background_color))
                ...

请注意,他们没有调用 .setLargeIcon

关于notifications - 通知 android 5。状态栏图标为空,大图标上通知图标为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29195320/

相关文章:

ios - APNS 保存通知

android - 来自广播接收者的通知

android - 修复了 WebView Android 中的文本大小(Lollipop)

android - 应用内通知

amazon-s3 - S3 跨账户通知

android - 如何实现像 Lollipop 这样的联系人详细信息屏幕

Android Material Design Inline Datepicker问题

android - 按来源更改颜色 actionBar Material 设计

android - Android Lollipop 设备 [Nexus 9 和 nexus 5] 上未显示菜单软键

iphone - 如何让我的 iPhone 应用程序显示顶部横幅提醒,例如 Mail 应用程序?