开发者

Android: TabHost Activity acting weird after kill / OnSaveInstanceState not called

I am not sure if I am doing something wrong, but as I just stumbled upon a similar bug, it might be another bug as well. I was wondering if you could confirm this or even know a solution?

Okay, so I have a Tab Host containing two Activities A and B.

A is the "first" tab. So if I do开发者_如何学Go the following:

  • (A is opened)
  • switch B
  • close app
  • kill the process
  • open app again
  • (B shows up)

then I everything is fine. Using Log I see that "onRestoreInstanceState" was called both for A and B.

Now, I do the following:

  • (B is opened, I have NOT switched back to A)
  • switch B
  • close app
  • kill the process
  • open app again
  • (B shows up)

then "onRestoreInstanceState" is called for B, but not for A. A get's a null Bundle in "onCreate".

If I switch to A, then back to B, it's fine again. After that, I can repeat the above behavior.

I know this sounds a bit confusing, but has anybody encountered this before?

Kind regards, jellyfish

Edit:

I've repeated this for the other tab (keep A open, kill the activity, restore it, kill it again, restore it again). Then, B's "onCreate" is not called until I deliberately switch the tab; and no matter if it was restored before or not, it always gets the SavedInstance Bundle. So everything is fine.

Edit2:

As excepted, the same is true for rotation changes. Has seriously nobody noticed this before? Got this working both on 2.2 emulator and 2.3 phone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜