Notification用法

1、创建NotificationManager管理通知,调用Context.getSystemService(Context.NOTIFICATION_SERVICE)

2、用Builder构造器创建Notification对象:Notification notification = new NotificationCompat.Builder(context).build();

3、可以再build()之前连接多个设置方法:setContentTitle()、setContentText()、setWhen()、setSmallIcon()、setLargeIcon()

4、调用notify(iid,nitification)

5、通过PendingIntent实现通知的跳转,用getActivity()、getBroadcast()、getService()获取PendingIntent对象。

6、setContentIntent(Pending对象)

7、取消通知.setAutoCancel(true)

此外还可创建其他通知效果.setSound()、.setVibrate()、.setLights()、.setDefaults()、.setStyle()、.setPriority()

原文地址:https://www.cnblogs.com/yl-saber/p/6407959.html