Android Notification使用及取消

//发送通知
NotificationManager manger = (NotificationManager) this.getSystemService(NOTIFICATION_SERVICE);
Notification noti = new Notification(R.drawable.icon,"电话录音",System.currentTimeMillis());
Intent it = new Intent();
it.setClass(this, MainActivity.class);//点击通知后要跳向的页面
PendingIntent pi = PendingIntent.getActivity(this, 0, it, 0);
noti.setLatestEventInfo(this, "电话录音", "正在监听...", pi);
noti.defaults = Notification.DEFAULT_ALL;//有4种
manger.notify( 10, noti);// id=10
 
//取消
NotificationManager manger = (NotificationManager)this.getSystemService(NOTIFICATION_SERVICE);
manger.cancel( 10);

你可能感兴趣的:(notification)