开发者

getIntent returns wrong intent when setIntent is followed by a rotation

I have the following scenario:

I have a chat activity, in it's intent it gets the email of the contact for which to show the messages, the activity has singleTop as it's launchmode

By sliding my finger over the screen I switch between different conversations, I do this by calling startActivity with the new intent: onPause will be called, followed by onNewIntent, in which I do setIntent, followed by onResume. In onResume I get the new intent, all good so far.

Then I change the orientation: onPause is called, followed by onDestroy, at this point getIntent returns the correct intent, followed by onCreate which has the old intent, followed by onResume, which also has the old intent

I've found this -> http://groups.google.com/group/android-developers/browse_thread/thread/7f0389f349e1ee3b to explain this behavior but it doesn't happen on my HTC desire with android 2.2, using the emulator I found it happens on 1.5, but not on 1.6

So my question: Is this normal on 1.5 ? If so, how can I change the behavior of the activity so this doesn'开发者_运维百科t happen again ?

I know I can change the launchmode from singleTop to standard but this will also affect android 1.6+ which I don't want because with singleTop, the changing of conversation goes fast (only onPause and onResume are called), with standard onCreate and onDestroy are also called...

Maybe there is something I can do with the intent flags I haven't found yet, the flags I change in the code so I can have a "if sdk is 3" check...

Thanks for reading, Danny


You can possibly work around it by overriding onRetainNonConfigurationInstance() and return the latest intent, which you can then retrieve using getLastNonConfigurationInstance().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜