I have got a small problem in an Android app I am working on :
There are 3 activities namely A , B , C and the invocation is in the following order : A -> B -> C.
You can start Activity C with startActivityForResult()
and inside onActivityResult()
finish Activity B.
To start Activity C,
Intent intent = new Intent(ActivityB.this, ActivityC.class);
startActivityForResult(intent, 123);
And override in Activity B
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 123){
if(resultCode == Activity.RESULT_OK){
finish();
}
}
}
And inside Activity C use setResult(Activity.RESULT_OK)
before finish();
UPDATE:
Another way is to use FLAG_ACTIVITY_NEW_TASK
and FLAG_ACTIVITY_CLEAR_TOP
to start Activity A from Activity C.
Intent intent = new Intent(ActivitC.this, ActivityA.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
One more way can be just finish()
Activity B when you are starting Activity C. So, when you press back on Activity C it will directly move to Activity A as Activity B has already finished.