1

I want my app to do is: Once a day check if the user have written a note, If not, add a notification to the statusbar, reminding the user to start the app, and write a note.

Can I use the alarm-manager or do I have to use a Service for this? Do anyone know where to find a good tutorial on this, or have some example code ?

Vidar Vestnes
  • 42,644
  • 28
  • 86
  • 100
  • Here's a **downloadable** example for scheduling alarms which will **survive reboots**: http://developer.android.com/training/scheduling/alarms.html – Phantômaxx May 14 '14 at 07:43
  • possible duplicate of [AlarmManager Android Every Day](http://stackoverflow.com/questions/4562757/alarmmanager-android-every-day) – Howli May 20 '14 at 20:37

1 Answers1

1

Use AlarmManager. Permanently running a Service just for scheduling a regular task would be an overkill.

Have a look at this question, for example: AlarmManager Android Every Day

Community
  • 1
  • 1
FD_
  • 12,947
  • 4
  • 35
  • 62
  • What if the user restart its phone, will the alarms still be running? – Vidar Vestnes May 14 '14 at 07:38
  • There is one problem with AlarmManager in KitKat OS can shift alarms, so if you need notification to be fired at exact time it's better to implement Sevice – Chaosit May 14 '14 at 07:40
  • Its not required to be at an exact time...Just sometime in the day, like between 6pm and 11pm is accurat enough. – Vidar Vestnes May 14 '14 at 07:41
  • 1
    @Chaosit even on KitKat, I'd discourage using a Service, but simply using `AlarmManager.setExact(int, long, android.app.PendingIntent)` in case such high accuracy is needed. – FD_ May 14 '14 at 07:43
  • By the way, it won't work after restart without rescheduling. – kupsef May 14 '14 at 10:09