Android菜鸟日记16-notification

Android菜鸟日记16
notification

notificationManager = (NotificationManager) ct
.getSystemService(ct.NOTIFICATION_SERVICE);
Notification notificaiton = new Notification(id, tickerTexT,
System.currentTimeMillis());
// 这个ID是notificaiton id
// 创建notification对象
PendingIntent ci = PendingIntent.getActivity(ct, 0, it, 0);
// PendingIntent为系统android 对象 负责可以脱离程序负责 notificaiton
notificaiton.setLatestEventInfo(ct, contentTitle, contentText, ci);
// 设置notification信息
notificationManager.notify(id, notificaiton);
// 这里的id是放入的图片R.DRAW.XX这个指向ID
// 这里的id可以和上面一样(我写的是一样的),也可以不一样 但是这里的id必须是图片指向id 上面的notificaiton id则无所谓。
// 但是一般使用的时候直接用图片的指向id 作为notificaiton的id.
// 对notificationManager传入notificaiton的ID和notificaiton对象。


使用notification
1.首先要从系统中获取NotificationManager服务
2.然后实例化Notification对象。
3.将当前活动注册到PendingIntent对象
活动注册到==PendingIntent传入=Notification
当活动关闭了。 Notification依旧可以通过PendingIntent去开启活动。
PendingIntent是由android系统负责维护的。
4.给Notification对象赋值。//(ct,contentTitle,contentText,ci);
5. notificationManager对象发出通知
通过notificationManager.notify(id, notificaiton)
将notificaiton对象发出。


2011-9-16
poolo
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值