I have three activities, a, b, c. Activity b will start activity c. In activity c when i press the back key, activity c will finish() and activity b will show just as it was left.
That is not that hard, what i am wanting to do is when i finish() activity c, i want to finish() activity b at the same time in order to show activity a.
Does anyone have any idea on how to finish an activity from another activity?
To achieve this best way is to use startActivityForResult and onActivityResult in conjugation.
From Activity A, start activity B and then from B start activity C for a result using startActivityForResult()
In Activity C, when the user triggers back or Destroy()
set a result that will inform A to finish as well,
Call finish() in C.
When B receives that result from C, B calls finish() on itself as well.
In the parent activity, while triggering the child activity, use the following command:-
and override the onActivityResult Method in the following manner in Activity B:-
Now, in the child activity C, override onStop and onDestroy in the following manner:-