2012-01-17 3 views
4

나는 안드로이드를 위해 잠시 동안 개발 해왔다. 그러나 이것이 알림에 대한 나의 첫 번째 발언이다. Android SDK 튜토리얼에 설명 된대로 알림 설정이 있지만 앱을 종료 할 때까지 알림을 유지하는 방법을 알 수 없습니다. 알림 끝 부분에 작은 마이너스 기호를 비활성화하고 싶습니다. 사용자가 클릭 할 때 알림이 사라지지 않게하고 싶습니다. 나는 신고 깃발이있을 것이라고 생각할 것이다. 그러나 나는 이것을 알아낼 수 없다. Android SDK 2.2에서 개발 중입니다. 나는 이것이 간단한 질문이라는 것을 알고 있으며,이 답변이 이미 여기에 있다면 사과드립니다 ... 나는 내가 찾고있는 것을 정확히 찾을 수 없었습니다.내 앱이 닫힐 때까지 Android 알림을 계속 표시하려면 어떻게해야합니까?

// Create notification manager 
    String ns = Context.NOTIFICATION_SERVICE; 
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns); 
    Notification notification = new Notification(R.drawable.ic_launcher, "Ready", System.currentTimeMillis()); 
    Intent notificationIntent = new Intent(this, HomeActivity.class); 
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); 

    // Make a notification 
    notification.setLatestEventInfo(getApplicationContext(), "Ready", "Select to manage your settings", contentIntent); 
    mNotificationManager.notify(0, notification); 

답변

5

FLAG_ONGOING_EVENT을 원합니다. 또한 FLAG_NO_CLEAR 및 FLAG_AUTO_CANCEL이 기본값의 일부인 경우 제거하십시오.

+0

나는 공식적으로 유죄입니다 내 대답이 질문을 다시 게시 : [대답 링크 (http://stackoverflow.com/questions/4983032/how-to-get-a-permanent-application-를 상태 표시 줄 알리미) ..... 감사합니다. jnnnnn. FLAG_NO_CLEAR은 내가 찾을 수없는 것입니다. 조금도! –

+0

notification.flags | = Notification.FLAG_ONGOING_EVENT; notification.flags & = ~ Notification.FLAG_NO_CLEAR; notification.flags & = ~ Notification.FLAG_AUTO_CANCEL; –

관련 문제