I am not sure how to describe my Problem. Basically I want to write an app, which reminds the user after a specific time (e.g. 1hr) of something. Unless he does not confirm the reminder, it will nag him every 10 mins, after the initial hour has passed.
Until the reminder pops up for the first time there will be 4 stages (eg. every 15mins), which should be shown inside the activity (eg with colors green, yellow, orange, red).
I implemented the reminder with a Broadcast Reciever and the AlarmManager, so far so good. But how can I check how long its been since the Alarm was set to find out in which stage I am? If the Activity is running in the foreground while the stage changes, the change should be made visible instantly. If the activity is started while the alarm is still counting down, the current stage should also be shown.
Anyone can point me in the right direction on how to do this in a good way, since I am still fairly new to Android.
Thank you.
[So far I basically followed this tut http://www.vogella.de/articles/AndroidServices/article.html%5D
You may want to maintain an int that represents the state of your counter. You can make it a member variable in your Activity, and you may want to persist it in shared preferences as well. To pass status change notifications from the alarm service back to your Activity, send an Intent. Your activity need not check up on the alarm counter; it can simply wait for the intents to roll in.