从网络服务我收到了数据列表。我必须显示收到数据的通知列表。要显示通知,我使用了以下代码。但是当我单击通知项时,我可以查看列表中的最后一个数据. 如何解决这个问题。
例如,如果列表项 1 的名称为“name1”,而列表项 10 的名称为“名称 10”。当我单击通知 1 时。它显示了有关列表项 10 的详细信息
ArrayList<MYObject> list= <List of data from webservice>
....
for(int i=1;i<list.size();i++){
createNotification(list.get(i),i);
}
.....
........
public void createNotification(MYObject obj,
int notificationId) {
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification myNotification = new Notification(
R.drawable.notification_icon, "Title!", System.currentTimeMillis());
String notificationTitle = "My Title";
String notificationText = "My Notification text";
Intent myIntent = new Intent(context.getApplicationContext(),
DetailView.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
myIntent.putExtra("detail", obj);
PendingIntent pendingIntent = PendingIntent.getActivity(
context.getApplicationContext(), 0, myIntent, 0);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.flags |= Notification.FLAG_NO_CLEAR;
myNotification.setLatestEventInfo(context, notificationTitle,
notificationText, pendingIntent);
notificationManager.notify(notificationId, myNotification);
}