Activity Lifecycle Android

Hi,

I was wondering if someone could guide me in the right direction to properly implement the activity lifecycle. The following logic is what I am trying to achieve.

Activity1
Activity2

                                       ----------------------------------------------------------------------------------
                                       |                                                             ^
                                       >                                                              |

OnCreateActivity1 -> RunActivity1 -> PauseActivity1 -> StartActivity2 -> Run Activity2 -> Finish Activity2

I have it all working accept when i try to recall activity1 from activity2 instead of going straight to the Run Activity it re creates the activity again. Is there away to go straight to the run cycle or does it need to be re created every time?

Thanks in advance.

Answers

  • ConorMurphyConorMurphy USMember

    Ignore the lines ... I was trying to show the cycle. When i finishActivity2 I want to then run Activity1 again.

  • ConorMurphyConorMurphy USMember

    Intent startActivity1 = new Intent (this, typeof(Activity1));
    resumeMainActivity.AddFlags (ActivityFlags.ReorderToFront);
    StartActivity(resumeMainActivity);

    The above code brings the background Activity back into run without recreating the activity.

  • rzee7rzee7 INUniversity ✭✭✭✭✭

    Hey @ConorMurphy Thanks! for snippet :)

Sign In or Register to comment.