Reputation: 427
SOLVED!
My Activity Stack looks like this, excuse the rough diagram!
A-->B-->C
'-->D
If I press back button in activity B
I go back to A
as expected.
However, if I press back button in Activity C
or D
I go back to A instead of B
.
In my mind this could be caused by two things
1)Activity B
quits when it opens the intents for C
or D
2)the back button is somehow being called twice?
I have looked closely at the click listeners in activity B
that start the intents expecting to find a finish()
call in there but there isn't.
I also check the onBackPressed()
methods of activites C
and D
to see if I was manually opening activity A...but I wasn't.
here's the onResume method of activity A
protected void onResume() {
super.onResume();
screenOn(SCREEN_ON_DURATION);
mWakeLock.acquire();
}
here's the way I'm starting intents C and D
Bundle info = new Bundle();
info.putString("classId", ""+classId );
Intent intent = new Intent(Notebook.this, StudentChooser.class);
intent.putExtras(info);
Notebook.this.startActivity(intent);
Can anyone help?
Edit: I discovered finish() in my onUserLeaveHint() that's what the problem was!
Upvotes: 4
Views: 1532
Reputation: 430
The reason may be that you are using finish() in your previous activity,For example
A->B->C
Intent intent = new Intent(B.this, C.class);
startActivity(intent);
finish();
finish() is destroying B activity hence the control is going on activity A on back button
Upvotes: 3