Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recreate Android activity when popped from back stack

Tags:

java

android

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.

like image 577
Andrej Naumovski Avatar asked Apr 09 '26 01:04

Andrej Naumovski


1 Answers

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

like image 196
Sivakumar Avatar answered Apr 11 '26 14:04

Sivakumar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!