Question

I have some things in my Android application that need to update once per Month. Everything is correct but how do I set the time?

Calendar cal = Calendar.getInstance();
 cal.add( ?, ?);

  alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);
Was it helpful?

Solution

See this question for getting the day of the month using Calendar()

Then, figure out what month the user is currently in using

cal.get(Calendar.MONTH_OF_YEAR)

and set your variable to the 29th of that month.

Consider February in this implementation ;)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top