2

I want to popup an alarm on selected day i.e. Monday ,Tuesday and so on. And at selected time on every week. I've an idea about interval but I don't know how to get the next day and popup alarm ?

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Richa
  • 3,165
  • 1
  • 22
  • 26

1 Answers1

0

You need to use the AlarmManager and get a WakeClock while processing the Intent in Service (make sure to release it and chose the right kind).

Here is a great example : https://stackoverflow.com/a/8801990/220710

To get the day current day of the week, look at this question : Android: how to get the current day of the week (Monday, etc...) in the user's language?

Then you would use :

setInexactRepeating(int type, long triggerAtMillis, long intervalMillis, PendingIntent operation)

Schedule a repeating alarm that has inexact trigger time requirements; for example, an alarm that repeats every hour, but not necessarily at the top of every hour.

Then you would need to set :

  • type = RTC_WAKEUP
  • intervalMillis = ms in a week
  • triggerAtMillis = System.currentTimeMillis() + ms to the next Monday, Tuesday or whatever
  • intent = the intent you want to fire to a Service that will process it.
Community
  • 1
  • 1
Emil Davtyan
  • 13,808
  • 5
  • 44
  • 66