알림을 클릭하면 자동으로 내 알림을 취소하고 싶습니다. 다음 코드는 Android 롤리팝 기기를 제외한 모든 기기에서 잘 작동합니다. Lollipop 기기에서 알림은 사용자가 스 와이프 한 경우에만 표시됩니다.Android Lollipop 알림 자동 취소 기능이 작동하지 않습니다.
@SuppressWarnings ("중단") 공공 무효의 sendNotification에 (INT ID가) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Test")
.setContentText("Jump to next screen")
.setDefaults(Notification.DEFAULT_SOUND)
.setAutoCancel(true);
mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE;
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(this, NextActivity.class);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent resultPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0,
resultIntent, 0);
//PendingIntent.FLAG_UPDATE_CURRENT
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
// id, if there is a need to update the notification later on.
mNotificationManager.notify(id, mBuilder.build());
Log.v(TAG, "Notification ID value " + id);
//mNotificationManager.cancel(id);
}
이 코드에서 누락은 무엇입니까?
심지어 내가이 문제를 참조하여 설정할 수있는 특별한 조건을 설정하려는 경우
을 다음을 수행합니다. 해결 방법을 찾을 수 있었습니까? 내가보기에, 그것으로 제거되고 하나의 새로 고침은 알림 센터에서 발생합니다. – Ayyappa
팔로우. 나는 너무 붙어있다. 이 모든 문제를 아직 파악하지 못했지만 아직 해결되지 않았습니다. 현재 타이머를 실행하고 타이머가 만료 된 후 모든 알림을 취소합니다. – LokiDroid