I'm fairly new to Android, so please forgive my naiveté.
The app I am working on needs to wake up every hour and do some background data collection. I'm using AlarmManager
to set a repeating alarm that starts the service.
I'm currently setting up the alarm in the MainActivity
in the onCreate
method. My concern is that if the app is closed and reopened and the onCreate
method is called again, it would duplicate the alarms. Am I incorrect in assuming this?
One way I'm thinking about circumventing this to use a boolean in SharedPreferences
. Is there a more standard way of approaching this issue?
Thank you!