android 图标提示数,在Android中如何计数通知数和显示单个图标?

看看这里的答案:

How to give counter if more than one Notifications are there

Notification notification = new Notification(R.drawable.direction, "Cool Notification",

System.currentTimeMillis());

/********LIKE THIS*********/

notification.number = notificationCount++;

/********LIKE THIS*********/

notification.setLatestEventInfo(context, "Cool Notification Title",

"updated notificaiton message", null);

NotificationManager nm = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);

nm.notify(R.id.my_motification, notification);

您必须通过NotificationManager.notify方法发送您的通知,所有这些方法具有相同的id.如文档所述,id是您应用程序中该通知的唯一标识符.如果您重复使用相同的ID,它将只更新该通知的文本和数字.

要查看用户何时点击通知,您需要提供一个PendingIntent(请参阅tutorial).要检查用户何时清除通知,您需要使用仅在Api级别11中可用的Notification.Builder.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值