This is the scenario. I’ve just stopped a thread a have pressed the back key to return to the previous activity, only problem is I want to execute a method when this happens so I thought I could override a method using something like this:
@Override protected void onResume() {
super.onResume();
}
But this seems to run when I start the activity. I want to have this functionality but when pressing the back key to return.
Sorry if it doesn’t make sense, I’m not very knowledgeable of the terminology.
According to the official documentation,
onResume()is exactly what you want – it always gets executed when the activity comes into foreground, either together withonCreate()and/oronStart()or alone, depending on the current process and activity states.