user1038715
user1038715

Reputation: 13

How to open an activity twice but with different content?

I'm developing a chat app, but I have a problem. I've a list with the contacts and when I select one contact I'm starting a new activity

Intent i = new Intent(this, MessageScreen.class);
startActivity(i);

but, when I choose another contact to talk I will use the same activity. but it always open with the last contact screen and the variables still with the old values.

I would like to make something similar to google talk, where you can start to talk with another contact, and all the messages use the same screen, and you can change between the chats fast with no need to reconstruct the screen, reload the messages, etc.. Anyone have any idea of how to implement this?

Upvotes: 1

Views: 865

Answers (2)

FunkTheMonk
FunkTheMonk

Reputation: 10938

Sliding between activities isn't a common feature, it sounds like there is one second activity that has a ViewPager that is populated with multiple chats. When starting this activity, they're probably adding the Reorder to front flag to the intent and have overridden onNewIntent to add a new view to the pager.

Upvotes: 1

poupou
poupou

Reputation: 43553

Try something like*:

i.PutExtra ("key", value); 

before starting the activity (e.g. store the user name) and then read your value from the activity and adjust (e.g. UI) it based on the value

note: syntax could differ a bit since I do my Android stuff from C#

Upvotes: 0

Related Questions