[英]Icon problems for GCM notification build with NotificationCompat.Builder
我创建推送通知如下:
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.app_name))
.setContentText(msg)
.setLights(Color.YELLOW, 250, 500)
.setAutoCancel(true)
.setVibrate(new long[] {100, 100, 100, 100})
.setSound(alarmSound)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
但是,在装有Android 5的Nexus 5上,我总是会看到一个迷你图标,而不是正常大小的启动器图标。
解决方案:对于Android 5,似乎有必要使用带有白色图标的透明背景。 使用LargeIcon确实可以在通知中心中使用,但不能在状态栏中使用。
我相信您还需要使用setLargeIcon
如果将其设置为使用启动器图标,则它应以正确的大小显示。 SmallIcon用于状态栏中弹出的图标。
您的启动器图标具有黄色背景,上面带有白色图标。 对于“小图标”,创建一个仅带有透明背景的白色图标的版本。 Android会自动将图标文件中的所有颜色设置为白色,这就是为什么它显示为大的白色正方形。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.