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");
}
}
如何糾正呢?