Skip to content Skip to sidebar Skip to footer

Setting Alarm On Monthly Basis Android

I am developing an android app for setting alarm on daily, weekly, monthly basis. The first two are working fine by converting the give date and time into milliseonds. But when I a

Solution 1:

By default, an integer literal in Java will be of type int, which is a 32-bit number. When you multiply an int by an int the result is also an int, so your result is being truncated. Obviously the argument to setRepeating is a long, but that doesn't mean the compiler will fix this for you - your multiplication will still be truncated.

The solution is to explicitly force the literals to be of type long, which is a 64-bit number:

am.setRepeating(AlarmManager.RTC_WAKEUP, alarmTimefor30, 30L*1440L*60000L , pi);

Post a Comment for "Setting Alarm On Monthly Basis Android"