【发布时间】:2015-04-20 15:42:12
【问题描述】:
我试图在我的服务和活动之间传递 HashMap。我知道如何使用自定义对象传递 Arraylist。 但未能找到从服务传递 hashmap 的解决方案。
我有服务从我想将 hashMap 发送到我的活动的地方
public void getpProperies(ArrayList<property> values){
if(values != null && values.size() > 0){
for(property si : values){
if(si instanceof esOtherProperty){
Log.d(TAG, "Data "+ ((esOtherProperty) si).name);
}
if(si instanceof esEmpProperty){
Log.d(TAG, "EMP Data "+ ((esEmpProperty) sig).name);
}
}
}
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("si", allvalues);
if(resultReceiver != null)
resultReceiver.send(100,bundle);
}
private HashMap<String, ArrayList<esProperty>> allvalues;
所以改为 bundle.putParcelableArrayList("si", allvalues),有没有办法传递 allvalues hashmap。我查看了 Bundle Class,但没有找到任何东西。
【问题讨论】:
-
putSerializable()怎么样?
标签: java android arraylist hashmap parcelable