I have an application where I extend Application class and override the onCreate method.
In my onCreate, I schedule a service to run every 5 minutes using AlarmManager.
In the logs, I see that onCreate get’s called again after a while as though the application was restarted / recreated.
this ends up with my service not being synchronized with the first execution.
Is there a way to prevent this and to guaranty code in Application’s onCreate will execute exactly once (assuming of course the application wasn’t explicitly closed by the user)?
Thanks
onCreate()on yourApplicationis called as part of starting up your process. If you are seeing it called several times in the logs, that is because your process was terminated in between runs.