在项目的页面跳转中,Activity启动顺序为:A—>B—->C——>A
其中A启动模式设置为android:launchMode=”singleTask” ,
当C跳转到A时,A将不再执行onCreate方法,而是直接执行onResume;
C通过intent传递参数给A,通过以下方式将无法获取。
[html] view plaincopy在CODE上查看代码片派生到我的代码片
@Override
protected void onResume() {
super.onResume();
Bundle bundle = getIntent().getExtras();
if (null != bundle) {
trande_Amount = bundle.getString("Amount");
}
}
解决方法:
[html] view plaincopy在CODE上查看代码片派生到我的代码片
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// must store the new intent unless getIntent() will return the old one
setIntent(intent);
}
原文链接:http://blog.youkuaiyun.com/lvxiangan/article/details/43084633
本文探讨了在Android应用中,当Activity启动顺序为A->B->C->A,且A设置为singleTask模式时,从C跳转回A如何避免onCreate方法执行并正确获取传递的数据。通过实现onNewIntent方法,可以确保数据在跳转过程中得以正确保存和获取。
1647

被折叠的 条评论
为什么被折叠?



