android - Android 在恢复 Activity 时会恢复 Intent extras 吗?

标签 android android-activity

在 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/

相关文章:

android - Firebase 在检查数据是否存在时始终为真

android - 使用 Activity 在 android 中实现回调

android - 如何在android中拥有全局菜单?

android - 设置SeekBar的进度颜色为透明

java - 安卓应用程序崩溃

android - 从后台返回应用程序时,保存在单例中的静态数据有时为空

android - 从保存在 Intent 中的 OnActivityResult 函数获取 ArrayList<Spanned>

java - 如何从 View 类重复另一个类中的 Activity

java - 识别用户何时开车、步行、骑自行车

android - 谷歌地图无法在某些设备上播放并且应用程序崩溃