Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onStop() not getting called when I press the back button

Tags:

android

Is this normal.

The docs say

"The onStart() and onStop() methods can be called multiple times, as the activity alternates between being visible and hidden to the user"

When I press the back button an it will go back to the previous activity which totally covers the old one.

What is going on here?

like image 852
jax Avatar asked Jul 24 '10 16:07

jax


1 Answers

onStop() is called each time Activity is no longer visible. So when back button is pressed onStop() is actually called.

Easy check, - need to put break points in onStop()/onStart() callbacks and run debugging session.

BUT note that onStop() of current Activity will most probably be called AFTER onStart()/onResume() of Activity to which you are switching.

Hence, I think you were trying to update something in onStop() of 1st Activity and were expecting to fetch updated data in onStart() of 2nd Activity which caused errors.

like image 178
Iurii Vasylenko Avatar answered Oct 01 '22 07:10

Iurii Vasylenko