Android中的服务:通过通知在服务和活动之间放置ArrayList

Android中的服务:通过通知在服务和活动之间放置ArrayList,android,service,android-intent,arraylist,parcelable,Android,Service,Android Intent,Arraylist,Parcelable,我从一个服务发送一个通知,内容是Parcelable ArrayList //my service code Intent intent = new Intent(mContext, AutoSearchActivity.class); //In this list, there is 3 elements intent.putParcelableArrayListExtra(Staff.JSON_ARRAY,staffs); PendingIntent pendingIntent = Pe

我从一个服务发送一个通知,内容是Parcelable ArrayList

//my service code
Intent intent = new Intent(mContext, AutoSearchActivity.class);

//In this list, there is 3 elements
intent.putParcelableArrayListExtra(Staff.JSON_ARRAY,staffs);

PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent , 0);

Notification notification = new Notification(
    R.drawable.toplogo, 
    (String) getResources().getString(R.string.notification),
    System.currentTimeMillis());

String titleNotification = (String) getResources().getString(R.string.notification_title);

String textNotification = (String) getResources().getString(R.string.notification_content);

notification.setLatestEventInfo(mContext, titleNotification,textNotification, pendingIntent);

notification.vibrate = new long[] { 0, 400, 100, 400, 100, 600 };

notificationManager.notify(ID_NOTIFICATION, notification);
点击我的通知后,将执行自动搜索活动。我试图捕获数据并显示它们,但只显示旧数据。我猜有一种缓存系统,但我不知道如何删除它

//in my AutoSearchActivity
Bundle bundle = getIntent().getExtras();

//only 1 element !!!
ArrayList<SiteStaff> listAppInfo = bundle.getParcelableArrayList(Staff.JSON_ARRAY);
//在我的自动搜索活动中
Bundle Bundle=getIntent().getExtras();
//只有一个元素!!!
ArrayList listAppInfo=bundle.getParcelableArrayList(Staff.JSON_数组);

谢谢你的帮助

是的,挂起的意图被缓存,造成了很多问题。把你的线路改成
pendingent pendingent=pendingent.getActivity(mContext,0,intent,pendingent.FLAG_UPDATE_CURRENT),强制挂起的意图只接受最新的值,即使它被多次激发。

是的,挂起的意图被缓存,会产生很多问题。把你的线路改成
pendingent pendingent=pendingent.getActivity(mContext,0,intent,pendingent.FLAG_UPDATE_CURRENT)强制挂起的意图获取唯一的最新值,即使它被多次激发。

谢谢你,我的朋友~它工作了!我第一次听说悬而未决的意图问题~谢谢!谢谢你,我的朋友~真管用!我第一次听说悬而未决的意图问题~谢谢!