Java Android广播如何发送和接收对象列表

Java Android广播如何发送和接收对象列表,java,android,list,Java,Android,List,我想刷新我的列表视图。在我的服务中,我正在准备物品清单。如何在ListView中发送和接收对象列表 我的服务 @Override public void onLocationChanged(Location location) { //populate list //send list sendLocationBroadcast(poiList); } private void sendLocationBroadcast(List<Poi> poi

我想刷新我的列表视图。在我的服务中,我正在准备物品清单。如何在ListView中发送和接收对象列表

我的服务

 @Override
    public void onLocationChanged(Location location) {
    //populate list
    //send list
    sendLocationBroadcast(poiList);
}
 private void sendLocationBroadcast(List<Poi> poiList) {

        Intent locationIntent = new Intent();
        locationIntent.setAction(LOACTION_ACTION);
        locationIntent.putExtra(LOCATION_MESSAGE, poiList.toString());

        LocalBroadcastManager.getInstance(this).sendBroadcast(locationIntent);

}
@覆盖
已更改位置上的公共无效(位置){
//填充列表
//发送列表
sendLocationBroadcast(poiList);
}
私有void sendLocationBroadcast(列表poiList){
意向位置意向=新意向();
位置意图。设置动作(动作);
locationIntent.putExtra(LOCATION_消息,poiList.toString());
LocalBroadcastManager.getInstance(this).sendBroadcast(locationIntent);
}
和主要活动

 @Override
        public void onReceive(Context context, Intent intent) {


            if (null != intent && intent.getAction().equals(LOACTION_ACTION)) {

                String locationData = intent.getStringExtra(LOCATION_MESSAGE);

                ArrayList<Poi> dataList = (ArrayList<Poi>) intent.getSerializableExtra("DATA_LIST");

            }

        }
@覆盖
公共void onReceive(上下文、意图){
if(null!=intent&&intent.getAction().equals(LOACTION\u ACTION)){
String locationData=intent.getStringExtra(位置信息);
ArrayList dataList=(ArrayList)intent.getSerializableExtra(“数据列表”);
}
}
如何纠正这一点

变化

locationIntent.putExtra(LOCATION_MESSAGE, poiList.toString());

读取数据

if (getIntent().hasExtra("data")) {
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null)
         ArrayList<Poi> dataList = (ArrayList<Venue>) bundle.getSerializable("arrayListVenue");
}
if(getIntent().hasExtra(“数据”)){
Bundle Bundle=getIntent().getExtras();
if(bundle!=null)
ArrayList dataList=(ArrayList)bundle.getSerializable(“ArrayList”);
}
并确保
Poi
对象上实现了Serializable

if (getIntent().hasExtra("data")) {
    Bundle bundle = getIntent().getExtras();
    if(bundle!=null)
         ArrayList<Poi> dataList = (ArrayList<Venue>) bundle.getSerializable("arrayListVenue");
}