开发者

Activity save state problem

I am new in android application development. I am working on a chat(IM) application. Activity A shows the contact list and activity B is the chat activity(conversation activity). From the A activity when i click on a contact entry(from the contactlist) i start activity B with that contact entry emailaddress(by putextra in the intent). Now i want to chat with another person and i click back button and go to t开发者_运维问答he activity A showing the list(contact).I click one entry and again start activity B with different emailadd(putextra in the intent).After sometimes i get back to listactivity A and choose previous person i was chating.

Now how can i stop creating new activity and load the previous activity from the stack with the previous state??????

Thanks in advance. Rawcoder


If you are asking how can have multiple instances of a top level activity, you cannot, there is only one top level activity.

Activities are created in a stack, when you create A from B then B is now at the top of the stack, when you press the back button you are telling android that the top level of the stack (current activity) is no longer needed and it gets removed.

You will have to save state yourself and restore it if that's what you need to do when B is recreated.

Similar Question

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜