添加通知动作时,图标有什么用(Android)?
When adding notification action, what is icon used for (Android)?
添加操作按钮时,您还必须提供图标
https://developer.android.com/training/notify-user/build-notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
.addAction(R.drawable.ic_snooze, getString(R.string.snooze),
snoozePendingIntent);
但是该操作在操作按钮上显示时没有图标:
图标显示在较旧的 OS 版本上,从不(据我记得 7+)通知的默认样式已更改并且图标已删除...您仅为较旧的设备设置此值并且也许有些从来没有自定义 rom(包括制造商改进)并保留这些按钮上的图标
请注意,您可以 provide own layout for notification 添加任意数量的图标,但它看起来永远不会与所有其他通知完全相同(OS 样式,通常由制造商“改进”)
添加操作按钮时,您还必须提供图标 https://developer.android.com/training/notify-user/build-notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.notification_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setContentIntent(pendingIntent)
.addAction(R.drawable.ic_snooze, getString(R.string.snooze),
snoozePendingIntent);
但是该操作在操作按钮上显示时没有图标:
图标显示在较旧的 OS 版本上,从不(据我记得 7+)通知的默认样式已更改并且图标已删除...您仅为较旧的设备设置此值并且也许有些从来没有自定义 rom(包括制造商改进)并保留这些按钮上的图标
请注意,您可以 provide own layout for notification 添加任意数量的图标,但它看起来永远不会与所有其他通知完全相同(OS 样式,通常由制造商“改进”)