2012-04-03 2 views
4

알림 바에 다른 알림을 게시하려고합니다.작업 완료시 명확한 알림을 피하는 방법

모두 ID가 다르지만 의도는 동일한 활동을 타겟팅합니다.

첫 번째 알림을 클릭하면 활동이 시작되고 완료되면 클릭합니다.

내 활동이 완료되면 막대에 남아있는 모든 알림이 사라집니다.

알림 표시 줄에 계속 나타나기를 바랍니다.

어떻게해야합니까?

여기 코드가 있습니다.

 mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 
         int id = 10; 
         notificationIntent = new Intent(context, MyAct.class); // creating intent. 
         notificationIntent.putExtra("data", data); 
         notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);   

         // defining actions while notification. 
         contentIntent = PendingIntent.getActivity(context, id,notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);    
         notification = new Notification(R.drawable.icon, message, 
           System.currentTimeMillis()); 
         notification.setLatestEventInfo(context, "Hello", message, 
           contentIntent); 

         notification.defaults |= Notification.DEFAULT_VIBRATE; 
         notification.defaults |= Notification.DEFAULT_LIGHTS; 
         notification.defaults |= Notification.DEFAULT_SOUND; 
         mNotificationManager.notify(id, notification); 
         id++; 

미리 감사드립니다 ....!

답변

3

의 방법 onNewIntent에 상태 표시 줄에 알림을 추가로 시도 할 수 있습니다.

 android:launchMode="singleTask" 
     android:taskAffinity="" 
     android:excludeFromRecents="true" 
0

알림을 잘못 작성한 것과 같은 소리가납니다. Notification.Builder 클래스에 대한 javadoc을 다시 읽으면서 잘못된 것을 확인하는 것이 좋습니다. setAutoCancel()을 호출하지 않았거나 동일한 객체를 다시 사용하여 알림을 게시 할 수 있습니다.

+0

ID의 활동 기반에서 알림을 수동으로 취소하고 있습니다. – Noby

관련 문제