I have 3 activities. Activity A which leads to activity B, which in turn can go back to activity A or start activity C. However, if I press back in activity C the app should
From Activity A, start activity B for a result using startActivityForResult(intent,19)
In Activity B, when the user triggers Activity C, start activity C.
startActivity() returns immediately, so
set a result that will inform A to finish as well,
Call finish() in B. and Call setResult() method before finish() method in your Child Activity In Parent Activity overide onActivtyResult(....) method. When A receives that result from B, A calls finish() on itself as well.
enter code here
@Override
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
//Added by Ashish to close parent activity
if(arg1==19){
finish();
}
super.onActivityResult(arg0, arg1, arg2);
}