Thank you. This is very useful advise that I already verified in my
test app as working. Small problem is it seems the hub activity
flickers a bit when launching next activity from onActivityResult (it
does not flicker the first time when startActivityForResult is called
from the hub's onCreate).

It still seems very weird to me that Android framework does not allow
bringing existing activity to the top similar to Back button behavior
and requires destroying and re-creating new instance.

On May 18, 10:10 am, blcooley <[email protected]> wrote:
> In that case, you could build a "hub" Activity that can start each of
> your four Activities via startActivityForResult, then have the
> Activities call setResult, passing back an identifier that the hub
> Activity inspects in onActivityResult and uses to determine the next
> Activity to start.
>
> That way, your Activities would get destroyed rather that stacking up
> until the OS decided to destroy them to reclaim the memory. The bad
> thing is that it might break user expectations with respect to the
> back button.
>
> On May 17, 9:09 pm, ls02 <[email protected]> wrote:
>
>
>
> > The activity stack in my real app is not hard coded. A can start B, or
> > C which can start D and D can start A or B or C depending on user
> > selection or other flow. And this happens rather frequently. Each of
> > them in reality should exist in only one instance and the activity
> > should be shown or brought to top rather then re-created. However, I
> > can handle re-creating activity when started from another activity, I
> > just need to ensure that previous activity instance is completely
> > destroyed and all its resources are de-alocated and freed.
>
> > On May 17, 9:56 pm, blcooley <[email protected]> wrote:
>
> > > If you need information from B to be fed back to A, then start B by
> > > calling startActivityForResult. Then, when B exits, call setResult,
> > > and A will be on top of the Activity stack and its onActivityResult
> > > will fire.
>
> > > If you don't need information from B, then you can start B using
> > > startActivity. A will still be on top of the Activity stack when B
> > > exits.
>
> > > Best regards,
> > > Brian Cooley
>
> > > On May 17, 7:16 pm, ls02 <[email protected]> wrote:
>
> > > > My understanding there is no way to start another activity reusing
> > > > existing activity instance. Both startActivity and
> > > > startActivityForResult create a new activity instance.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]
> > > For more options, visit this group 
> > > athttp://groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group 
> > athttp://groups.google.com/group/android-developers?hl=en-Hide quoted text -
>
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to