具体实现如下:
class TrackingThread extends Thread{ String result; String status; int state; Bundle bundle=new Bundle(); @Override public void run() { try{ getTrackingDAL=new GetTrackingiDAL(TrackingService.this,DeviceID,Time,Map); result=getTrackingDAL.GetTrackingForMulti(); status=getTrackingDAL.getTrakingState(result); state=Integer.parseInt(status); trackinglist=getTrackingDAL.getTrackingForMultiresult(result); }catch (Exception e){ e.printStackTrace(); } ArrayList arrayList=new ArrayList();//用于传递list的集合 arrayList.add(tracking); bundle.putStringArrayList("Trackinglist",arrayList); Message msg=new Message(); msg.obj=tracking; msg.what=state; msg.setData(bundle); trackingHanlder.sendMessage(msg); } } private Handler trackingForMultiHanlder=new Handler(){ @Override public void handleMessage(Message msg) { if(msg.what==0){ ArrayList arrayList=msg.getData().getParcelableArrayList("Trackinglist"); trackinglist=arraylist.get(0); timerIntent.putParcelableArrayListExtra("Arraylist_tracking",arrayList); timerIntent.putExtra("state", msg.what); timerIntent.setAction(Constant.TRACKING_ACTION_FOR_MULTI); sendBroadcast(timerIntent); }bundle.putParcelableArrayList这里,通过这个方法设置到bundle里的对象必须实现了parcelable接口,否则在对象序列化过程中没有实现这个接口的对象就不会序列化,最终put进去的值是null,你传递的实际上是一个ArrayList<List<trackingInfo>>对象,Work这个类没有实现Parcelable这个接口,