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);
}
1을 i로 변경하면 작동할까요? – aratn0n
@ aratn0n 예, 작동합니다. – Egor
고맙습니다. 이제 작동합니다. – aratn0n