活动就会被杀死,但保存的包不在的onCreate收 [英] Activity gets killed but saved bundle is not received in onCreate

查看:102
本文介绍了活动就会被杀死,但保存的包不在的onCreate收的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有工作没有碎片的应用程序。 我修改活动使用的片段。 问题是,现在当活动进入后台,然后在前台再次的onCreate被称为:它看起来像活动就会被杀死,以节省内存或因其他原因

I have an application that works without fragments. I modified an activity to use fragments. The problem is that now when the activity goes in background and then in foreground again the onCreate is called: it looks like the activity gets killed to save memory or for another reason.

我想保存的onSaveInstanceState捆绑但活动再次打开时,我收到一个空包在OnCreate和onRestoreInstanceState没有调用(我检查,我接到一个电话在后台准备时的onSaveInstanceState)。

I tried to save a bundle in onSaveInstanceState but when the activity is opened again I receive a null bundle in the onCreate and no call to onRestoreInstanceState (I checked that I receive a call to onSaveInstanceState when going in background).

任何线索?

感谢

推荐答案

我最近更新了我使用的片段首次应用。我创建了包中的onSaveInstanceState,然后我找回包的onActivityCreated。这两种方法都在片段派生类中!也许你正在创建的束在片段,然后试图检索它的活动?

I recently updated my first application to use Fragments. I create the bundle in onSaveInstanceState and then I retrieve the bundle in onActivityCreated. Both methods are in the Fragment derived class! Maybe you're creating the bundle in the Fragment and then trying to retrieve it in the Activity?

这篇关于活动就会被杀死,但保存的包不在的onCreate收的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆