gpt4 book ai didi

java - 将 HashMap 发送到其他 Activity 时如何修复 InvocableTargetException

转载 作者:行者123 更新时间:2023-12-02 09:27:28 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com