Running multiple actions in a chain

Hi Android developers.

I have three activities that are triggered in some kind of chain.

Activity A -> has a trigger button that triggers activity B.

Activity B -> Cancel, which goes back to Activity A. And a capture button, which launches Activity C with some data.

Activity C -> back button that goes back to activity B which should resume activity A with some data.

My question is the correct way to start these activities in the chain and how can I keep the flow from Activity C to A.

+3


source to share


3 answers


Activity A -> has a trigger button that triggers activity B.

Start a new activity like

Intent myIntent = new Intent(A.this, B.class);
        startActivityForResult(myIntent);

      

Activity B -> a cancel button that reverts back to Activity A. And a capture button that starts Activity C with some data.



In undo mode you can just call finish()

, and on the capture button you can start a new activity C.

Action C -> back button which falls back to using activity B, which should resume activity A with some data.

on the return button you can call finish()

and if you want to get any input from Activity A then you should call StartActivityForResult(1212)

and get this code to onActivityResult

do the operation you want and end () Action A when you do it it will be automatically redirected to Activity C, in Activity C onResume()

you will be able to get this data value.

0


source


Skills are the best way to move from one activity to another Activity.Code



public void onClick(View v)
{
    Intent myIntent = new Intent(A.this, B.class);
        startActivityForResult(myIntent, 0);
}

      

+1


source


You can start Activity C from Activity B as startActivityForResult (intent, requestCode). Back from activity C to B, get the result of the activity onActivityResult.

You can do the same workflow for C and A and vice versa. See this

0


source







All Articles