private void sendCustomNotification(){ final Notification.Builder builder = getNotificationBuilder(); RemoteViews remoteViews =new RemoteViews(getPackageName(),R.layout.activity_main); remoteViews.setTextViewCompoundDrawablesRelative(R.id.tv_title,"biaoti"); remoteViews.setTextViewCompoundDrawablesRelative(R.id.tv_content,"neirong"); //即将要发生的意图,他可以被取消和更新 Intent intent=new Intent(this,NotificationIntentActivity.class); PendingIntent pendingIntent=PendingIntent.getActivities(this,-1,intent,PendingIntent.FLAG_UPDATE_CURRENT); remoteViews.setOnClickPendingIntent(R.id.trun_next,pendingIntent); //用户listview 包含点击事件用这个 // remoteViews.setOnClickFillInIntent(R.id.trun_next,intent); builder.setCustomContentView(remoteViews); getManager().notify(3,builder.build()); }
取消id为3的通知
getManager().cancel(3);