简体   繁体   中英

Notification icon detection

当在android的通知菜单中获取的json中插入新节点时,如何更改通知图标的颜色。

So if as in the comments, if what you want to do is display a notification with a color, and then update the same notification with a different color, you can try this:

First, when launching the notification set a fixed notificationID , for example:

notiManager.notify(123, notiBuilder.build());

I also think you may want to set the flag PendingIntent.FLAG_UPDATE_CURRENT on the pending intent of your notification.

And to set the color of the notification:

notiBuilder.setColor(ContextCompat.getColor(mContext, R.color.colorPrimary));

If you what to set a default color and then change it when a new one arrive I suggest you to save the count in the SharedPreferences and set the color according to the notification count

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM