0
我想刷新我的ListView。在我的服务中,我准备了对象列表。如何发送对象列表并在ListView中接收?Android广播如何发送和接收对象列表
我的服务
@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);
}
及主要活动
@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");
}
}
如何纠正呢?