Which method gets called in the parent activity when the user clicks on Back in the child activity?

StackOverflow https://stackoverflow.com/questions/20669504

  •  19-09-2022
  •  | 
  •  

Question

I have 2 activities in my Android app: A and B. A is the parent of B, as defined in the Android manifest. When stepping through my app with the debugger I've found that when I click on Up in the child activity, B, the onCreate() method of A gets called. But where does control pass to when the user clicks on Back in activity B? Which method of its parent activity, A, gets called?

I've read lots of stuff about navigation in Android, Back vs Up, etc., but I can't find an answer to this simple question. (I would like the Back button to behave like Up in my app but I can't get A's screen to update correctly when the user clicks on Back in B.)

Was it helpful?

Solution

At least onResume() will be called when activity A becomes active again.

OTHER TIPS

override onBackPressed method of activity A it will called when you press Back on Activity B

 @Override
public void onBackPressed()
{
     // code here to show dialog
     super.onBackPressed();  // optional depending on your needs
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top