통지를 취소하려고합니다. 다른 통지가 첫 번째 통지보다 15 초 이내에 보내려는 경우 사용자에게 전송되도록 요청했습니다.표시되기 전에 안드로이드 예약 알림을 취소하십시오.
글로벌 변수 :
이
내 코드입니다public NotificationManager nm;
통지 기능 : 그 나타났습니다
final NotificationCompat.Builder b = new NotificationCompat.Builder(this);
b.setAutoCancel(true)
.setDefaults(NotificationCompat.DEFAULT_ALL)
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_launcher))
.setContentTitle(title)
.setContentText(message);
if (nm != null) {
Log.d(TAG, "notifyThis: cancelled");
nm.cancelAll();
} else {
Log.d(TAG, "notifyThis: not cancelled");
}
nm = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
nm.notify(1, b.build());
Log.d(TAG, "notifyThis: notify");
}
}, 15000);
통지가 게시 될 때까지 널 남아 나노 그래서이 방법 아무튼 문제는 없지만 알림을 만든 후 알림을 삭제하고 .notify에 게시하기 전에 알림을 제거 할 수있는 방법이 필요합니다.
감사합니다.
완전한 예를 보여주십시오. 클래스 및 메서드 선언을 포함해야합니다. –
alarmManager.cancel (pendingIntent)를 호출 할 수 있습니다. 더 많은 것을 여기에서 읽으십시오 : http://stackoverflow.com/questions/30075196/how-can-i-cancel-unshown-notifications-in-android –