How to set alarms in android -


i newbie android.

i developing prayer application. functionality user set time , @ particular time prayer played entire month.

so doing in manner:

for (int counteralarm = 0; counteralarm < spandays; ++counteralarm) {               alarmpendingintent = creatependingintent(context,                     string.valueof(100 + counteralarm));             setalarmforday(context, calendarmorningreminder,                     alarmpendingintent);             calendarmorningreminder.add(calendar.day_of_month, 1);             sbrequestcodes.append(string.valueof(100 + counteralarm));             sbrequestcodes.append(";");         } 

the above loop add alarms days, suppose user chosses time 6.00 in morning on 1st day of month 30 alarms registerd.

private static pendingintent creatependingintent(context context,             string requestcode) {         intent intent = new intent(context, applicationbroadcastreceiver.class);         intent.setaction(constants.intent_action_alarm_raised);          return pendingintent.getbroadcast(context,                 integer.parseint(requestcode), intent,                 pendingintent.flag_update_current);     }      @suppresslint("newapi")     private static void setalarmforday(context context, calendar calendar,             pendingintent pintent) {          alarmmanager alarmmanager = (alarmmanager) context                 .getsystemservice(context.alarm_service);          if (android.os.build.version.sdk_int >= android.os.build.version_codes.kitkat) {             alarmmanager.setexact(alarmmanager.rtc_wakeup,                     calendar.gettimeinmillis(), pintent);         } else {              alarmmanager.set(alarmmanager.rtc_wakeup,                     calendar.gettimeinmillis(), pintent);         }     } 

so have 2 questions :

  1. registering 30 alarms approach enough in android. or there better approach solve ?

  2. our application backward compatible android gingerbread, have used setexact() method version greater kitkat , set() method other lower versions. approach god enough ?

please help.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -