[英]Android - Change Notification Icon
我想知道是否可能有与启动器或应用程序图标不同的Notificationbar图标。 我想为我的推送通知显示另一个图标。 这可能吗? 谢谢。
对于API <11, Notification
构造函数允许指定图标 。 对于API> 10,用于Notifcation.Builder的setSmallIcon
和setLargeIcon
方法允许很多事情。
Notification n = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent)
.setAutoCancel(true)
.addAction(R.drawable.icon, "Call", pIntent)
.addAction(R.drawable.icon, "More", pIntent)
.addAction(R.drawable.icon, "And more", pIntent).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
在上面的代码中, setSmallIcon
和setSmallIcon
用于更改通知图标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.