I have a method that runs when the app is opened. It is called from onCreate. But I also call it from onResume. The problem I have is that at the moment it is running twice when the app opens. Is there a way to stop this or a better way to implement what I am trying to achieve?
Thanks
When an activity starts, onCreate()
is called first and then onResume()
is called,if you want it to be called only once, remove the call in onCreate()
.
calling the method in onResume() will ensure that the method is called when the activity regains focus, like after back press etc..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With