Andrej Naumovski
Andrej Naumovski

Reputation: 573

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.

Upvotes: 3

Views: 773

Answers (1)

Sivakumar
Sivakumar

Reputation: 191

when you moved from activity to settings then, Activity will go to onStop(). So, you can call onRestart() method in onStop() method will resume your Activity. Hope this option will help.

Or if this link is your case then u can find answer on same page.
How can I return back to my Activity from GPS settings window

Upvotes: 2

Related Questions