我正在尝试使用 startActivity(intent) 发送 HashMap 来启动新 Activity 。
我从这个链接中找到了答案: How to send hashmap value to another activity using an intent
但我仍然收到错误
当然,我尝试发送字符串
intent.putExtra("test","some String");
startActivity(intent);
它成功了
我的代码:
HashMap<String,Diner> dinersOrdersHasMap = new HashMap<String,Diner>();
FillHashMap(); // Fill the HashMap with data
Intent intent = new Intent(this, BillForm.class);
intent.putExtra("dinersOrderHashMap",dinersOrdersHasMap);
startActivity(intent);
异常(exception):
"Could not execute method for android:onClick", e);
e.detailMessage = "Parcelable encountered IOException writing serializable
object (name = com.example.myfirstapp.Diner)
当我打电话时
startActivity( Intent );
最佳答案
你的 Diner 类是可序列化的还是可打包的?
您可以在这里发布您的 Diner 类(class)吗?
关于java - 将 HashMap 发送到其他 Activity 时如何修复 InvocableTargetException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58237930/