항상 백그라운드에서 실행중인 서비스로부터 상태 표시 줄 알림을 만듭니다. 사용자가 5 분 동안 탭하지 않으면 알림을 취소하고 싶습니다.pendingIntent getBroadcast : 상태 표시 줄 알림이 이미 사용자가 탭했는지 확인합니다.
그래서 상태 표시 줄 알림이 활성 상태인지 어떻게 확인합니까 ??
FLAG_NO_CREATE로 getBroadcast를 보류 할 수 있다는 것을 알았습니다. Null을 반환하면 상태 표시 줄 알림이 여전히 활성화되어 있음을 의미합니다. 하지만 나를 위해 알리 스는 상태 표시 줄 알림이 활성화되어 있어도 null을 반환합니다. 아래 코드를 찾으십시오.
내가 잘못하고 있으면 알려주십시오.
코드 :
/* Notification intent creation */
Intent notificationIntent = new Intent(Intent.ACTION_MAIN, null);
notificationIntent = new Intent(Intent.ACTION_MAIN, null);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.ActivityTrackingUI", "com.ActivityTrackingUI.Main");
notificationIntent.setComponent(cn);
/* check */
if(PendingIntent.getBroadcast(this, 0, notificationIntent, PendingIntent.FLAG_NO_CREATE) != null)
{
Log.e("","notification present");
}
else
Log.e("","notification not present");
항상 알림 당신은 PendingIntent.getBroadcast에 두번째 매개 변수로 올바른 requestCode가 값을 제공해야