Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. how to set alarm to repeat monthly

how to set alarm to repeat monthly

Scheduled Pinned Locked Moved Android
tutorial
4 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharath1984
    wrote on last edited by
    #1

    Hi Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram. repeatTime=(AlarmManager.INTERVAL_DAY*31); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi); Thanks, Sharath

    L D A 3 Replies Last reply
    0
    • S sharath1984

      Hi Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram. repeatTime=(AlarmManager.INTERVAL_DAY*31); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi); Thanks, Sharath

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to add logic to calculate how many days to add, depending on the number of days in the current month. Then each time your application runs it sgould reset the alarm to the new value.

      1 Reply Last reply
      0
      • S sharath1984

        Hi Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram. repeatTime=(AlarmManager.INTERVAL_DAY*31); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi); Thanks, Sharath

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        As you are already (hopefully) aware, hard-coding numbers into your code is a bad idea. When are you wanting the alarm set for (e.g., the last day of the month)?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

        1 Reply Last reply
        0
        • S sharath1984

          Hi Currently I am working on an application to set reminders on monthly basis. I am not able to provide the correct repeating interval for my alarmmanager. Pls provide info about the same. this is my code, but this will not raise alarm for Feb or months having 30 days. Also pls provide code to set yearly repeating alaram. repeatTime=(AlarmManager.INTERVAL_DAY*31); mAlarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, when.getTimeInMillis(), repeatTime, pi); Thanks, Sharath

          A Offline
          A Offline
          alvachristi
          wrote on last edited by
          #4

          Hey, I tried this code in my app.In this app multiple alarms were set with different repeating time intervals. I used calendar object to add month and year accordingly and again set it for next alarm.i used code like this(for scheduling it for next month)- PendingIntentsender=PendingIntent.getBroadcast(context,Integer.parseInt(Long.toString(id)), intent1, 0); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(calendar.getTimeInMillis()); calendar.add(Calendar.SECOND, 30); AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); calendar.add(Calendar.MONTH, 1); am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender); Hope this works!

          Android application development

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups