3

Hello android developers

I have three Activities, which are started in some kind of chain.

Activity A -> has start button,which starts Activity B.

Activity B -> cancel button,which returns back to Activity A. And capture button,which starts activity C with some data.

Activity C -> retake button,which returns back to Activity B use,which must resume activity A with some data.

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

Dory
  • 7,462
  • 7
  • 33
  • 55

3 Answers3

1

Intents are the best way to move from one activity to other Activity.Code

public void onClick(View v)
{
    Intent myIntent = new Intent(A.this, B.class);
        startActivityForResult(myIntent, 0);
}
Sammar javed
  • 153
  • 1
  • 5
0

You can start activity C from Activity B as startActivityForResult(intent,requestCode). While returning back from activity C to B get results implemet onActivityResult.

You can do same workflow for C to A and wise-versa. Refer this

Community
  • 1
  • 1
user1621629
  • 765
  • 7
  • 19
0

Activity A -> has start button,which starts Activity B.

Start new Activity like

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

Activity B -> cancel button,which returns back to Activity A. And capture button,which starts activity C with some data.

On cancel button you can simply call finish() , and on capture button you can start new activity C .

Activity C -> retake button,which returns back to Activity B use,which must resume activity A with some data.

on retake button you can call finish() , and if you want to get some input from Activity A then you should call StartActivityForResult(1212) and Receive that code in onActivityResult make the operation that you want in it and finish() Activity A when you done , it will autonetically redirect to Activity C , in Activity C's onResume() you can able to retrieve that data value .

dharmendra
  • 7,835
  • 5
  • 38
  • 71
  • thanks for reply.. I have another button on activity c which should navigate to activity A,with some result. – Dory Feb 13 '13 at 06:28
  • hey dhams, but i would create Activity A again. – Dory Feb 13 '13 at 06:53
  • I have some inputs to get from user in Act A,and if I start Act A from Act C,it would create Act A again and whatever inputs user have entered before navigation will not remain. – Dory Feb 13 '13 at 07:02
  • i see . you question is little tweaky to understand , anyways i have edited again – dharmendra Feb 13 '13 at 07:14