the_prole
the_prole

Reputation: 8985

How to initialize an activity from another activity

I have activities A and B. Activity B is started by a service while the application is closed and activity A is not on the stack. Activity A has members that B requires access to. I would also like the home button to open activity A from Activity B even if activity B is started from a service. Is there a way to inject activity A back into the stack?

Upvotes: 0

Views: 957

Answers (3)

Exceptional
Exceptional

Reputation: 3004

That won't be a good decision, better use the members in the B Activity and Once Activity B is launched and it's about to leave just give intent to Activity A. Also you can check if Activity A is already in the stack. If already in the stack, it will popup by itself, if not found, can pro grammatically trigger it.

Upvotes: 0

Sourabh Bans
Sourabh Bans

Reputation: 3134

In your Service start ActivityA not ActivityB and pass some parameter to ActivityA.. and in ActivityA's OnCraete method launch the ActivityB.. now you have both in the stack.

Upvotes: 2

Gagan
Gagan

Reputation: 755

You can declare the logical parent of each activity in your manifest file, using the android:parentActivityName attribute (and corresponding element),for home button working.

And to add a activity back to stack Check this link for more details.

Upvotes: 0

Related Questions