gpt4 book ai didi

android - Intent bundle 变量未在 Activity 之间传递

转载 作者:行者123 更新时间:2023-11-30 03:16:02 24 4
gpt4 key购买 nike

mActivity.this 中我设置了一个 intent 和一个 bundle

Intent intent = new Intent(mActivity.this, nextActivity.class);
Bundle mBundleNow = new Bundle();
mBundleNow.putString("formattedAddress", formattedAddress);
mBundleNow.putDouble("latitude", latitude);
mBundleNow.putDouble("longitude", longitude);
mBundleNow.putString("newRequest", ""); //should probably be bool
intent.putExtras(mBundleNow);

当我运行 startActivity(intent) 时,intent 和 bundle 映射被填充。

nextActivity.classonCreate方法中,getIntent().getExtras()不为null,但是没有map,我设置的变量都不存在。

这是怎么回事?以及如何正确包含我的 Intent 变量

最佳答案

而不是 bundle ,试试这个:

intent.putExtra("varName", varValue);

关于android - Intent bundle 变量未在 Activity 之间传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20126081/

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