在 Android Activity 生命周期中,当 Activity.onCreate() 在恢复后被调用时(IE。不是在最初创建 Activity 或响应屏幕旋转时)此代码会返回有效(非空)Bundle 吗?
public void onCreate(Bundle savedInstanceState) {
Bundle b = this.getIntent().getExtras();
// is b == null? (when activity is resumed)
}
我正在尝试重现应用程序长时间未使用时出现的问题 - 当用户返回时,应用程序崩溃。
最佳答案
okay, so when Android kills my app and the user navigates back - onCreate() is fired with a >new< Activity, and the original Intent along with it's associated Extras is gone; or do the Extras get attached to the new Intent by Android?
我也在想同样的事情,并在我的应用程序中快速测试了这一点。
事实证明,当您的应用程序被杀死后重新创建一个 Activity 时,额外的 Intent 是可用的。
关于android - Android 在恢复 Activity 时会恢复 Intent extras 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8565137/