Andrej Naumovski Andrej Naumovski - 23 days ago 4x
Java Question

Recreate Android activity when popped from back stack

I have an Android activity which checks if the user's GPS is turned on and gives the choice to go Settings to turn it on if it's off. However, when I return from Settings and pop my activity from back stack, I want onCreate() to run again and execute code which uses my location. I have tried running recreate() in the onResume() method, however in that case it will not load my activity at all.

Any suggestions on how to execute this task are welcome. Thank you.


onCreate is called just one time. The code you are using in onCreate, move to onStart.

Activity lifecycle

Read more about Activity lifecycle.