2013-02-21 5 views
0

데이터베이스에서 쿼리하는 객체가 ArrayList이고 사용자가 알림을 터치 할 때 내 객체를 모두 제거하도록 통지하고 싶습니다.Android에서 다중 알림 처리

개체의 각 ID를 의도적으로 넣고 제거하려고하지만 문제는 알림의 첫 번째 항목의 ID가 맞지만 다른 ID는 첫 번째 ID가 아니라는 것입니다.

PendingIntent pI = PendingIntent.getActivity(getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT); 

를 호출 할 때 값 "1"과 정적 요청 ID를 제공하기 때문에이 문제가 발생 코드

for(int i=0;i<listItem.size();i++){ 
     String message = "Remove \""+listItem.get(i).getName()+"\" "+listItem.get(i).getID(); 
     intent.putExtra("id", listItem.get(i).getID()); 
     String s = intent.getExtras().getString("ID"); 
     Toast.makeText(getApplicationContext(),"id : "+s, Toast.LENGTH_SHORT).show(); 
     Notification notification = new Notification(R.drawable.icon_noti,message,new Date().getTime()); 
     PendingIntent pI = PendingIntent.getActivity(getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
     notification.flags = Notification.FLAG_AUTO_CANCEL; 
     NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
     notification.setLatestEventInfo(getApplicationContext(), message, "Touch to remove" , pI); 
     notification.sound = soundUri; 
     notificationManager.notify(i,notification); 
    } 

답변

3

, 그래서 방법은 같은 PendingIntent 당신에게 모든 시간을 반환 . 모든 항목에 대해 다른 PendingIntents을 만들려면 모든 통화에 대해 고유 한 요청 ID를 제공하십시오. 희망이 도움이됩니다.

+0

1을 i로 변경하면 작동할까요? – aratn0n

+0

@ aratn0n 예, 작동합니다. – Egor

+0

고맙습니다. 이제 작동합니다. – aratn0n