android Notification实例详解
1.使用Builder模式来创建
2.必须要设置一个smallIcon,还可以设置setTicker
3.可以设置 setContentTitle,setContentInfo,setContentText,setWhen
4.可以设置setDefaults(闪屏,声音,震动),通过Notification设置flags(能不能被清除)
5.发送需要获取一个NotificationManager(getSystemService来获取);notify(int id,Notification)
6.清除 manager.cancelAll(清除所有) cancal(int id); 如果需要16一下的api也能访问,需要导入v4包,使用notificationCompat兼容类。
自定义通知
使用RemoteViews来建立一个布局,然后使用setContent()设置;
点击事件使用PendingIntent来完成
下面是一个案例
MainActivity类
publi