在活动之间传递参数后的空值

时间:2018-05-24 16:25:16

标签: android

我需要在两个活动之间传递两个Hashmaps。我一直试图通过意图传递它,但是当新活动开始时,我的HashMap为空,而第二个正确传递。你知道为什么会这样吗?

这是我使用HashMap开始新活动的方式:

routeIntent.putExtra("routeMap", routeMap);
routeIntent.putExtra("stopsMap", stopsMap);
startActivity(routeIntent);

我是如何在新活动中收到参数的:

HashMap<String, String> routeMap = (HashMap<String, String>) this.getIntent().getSerializableExtra("routeMap");

HashMap<String, String> stopsMap = (HashMap<String, String>) this.getIntent().getSerializableExtra("stopsMap");

当我打印stopsMap的值时,它就是null。在有意图发送参数时,参数的大小或数量是否有限制?

0 个答案:

没有答案