src/android/notification/Notification.java
void schedule(Request request, Class<?> receiver) {
        List<Pair<Date, Intent>> intents = new ArrayList<Pair<Date, Intent>>();
        Set<String> ids = new ArraySet<String>();
        AlarmManager mgr = getAlarmMgr();

        cancelScheduledAlarms();

        do {
            Date date = request.getTriggerDate();


            if (date == null)
                continue;

            Intent intent = new Intent(context, receiver)
                    .setAction(PREF_KEY_ID + request.getIdentifier())
                    .putExtra(Notification.EXTRA_ID, options.getId())
                    .putExtra(Request.EXTRA_OCCURRENCE, request.getOccurrence());

            ids.add(intent.getAction());
            intents.add(new Pair<Date, Intent>(date, intent));
        }
        while (request.moveNext());

        if (intents.isEmpty()) {
            unpersist();
            return;
        }
        persist(ids);
      
        if (!options.isInfiniteTrigger()) {
            Intent last = intents.get(intents.size() - 1).second;
            last.putExtra(Request.EXTRA_LAST, true);
        }

        for (Pair<Date, Intent> pair : intents) {
            Date date = pair.first;
            long time = date.getTime();
            Intent intent = pair.second;

            if (!date.after(new Date()) && trigger(intent, receiver))
                continue;
            PendingIntent pi = PendingIntent.getBroadcast(
                    context, 0, intent, FLAG_CANCEL_CURRENT);

            try {
                switch (options.getPrio()) {
                    case IMPORTANCE_MIN:
                    case IMPORTANCE_LOW:
                        mgr.setExact(RTC, time, pi);
                        break;
                    case IMPORTANCE_MAX:
                    case IMPORTANCE_HIGH:
                        if (SDK_INT >= M) {
                            mgr.setExactAndAllowWhileIdle(RTC_WAKEUP, time, pi);
                        } else {
                            mgr.setExact(RTC, time, pi);
                        }
                        break;
                    default:
                        mgr.setExact(RTC_WAKEUP, time, pi);
                        break;
                }
            } catch (Exception ignore) {
                // Samsung devices have a known bug where a 500 alarms limit
                // can crash the app
            }
        }

    }
/**
     * Schedule the local notification.
     *
     * @param request  Set of notification options.
     * @param receiver Receiver to handle the trigger event.
     */
Schedule the local notification.
@param request  Set of notification options.
@param receiver Receiver to handle the trigger event.
Schedule the local notification . @param request Set of notification options . @param receiver Receiver to handle the trigger event .
void schedule(Request request, Class<?> receiver) {
        List<Pair<Date, Intent>> intents = new ArrayList<Pair<Date, Intent>>();
        Set<String> ids = new ArraySet<String>();
        AlarmManager mgr = getAlarmMgr();
        cancelScheduledAlarms();
        do {
            Date date = request.getTriggerDate();
            if (date == null)
                continue;
            Intent intent = new Intent(context, receiver)
                    .setAction(PREF_KEY_ID + request.getIdentifier())
                    .putExtra(Notification.EXTRA_ID, options.getId())
                    .putExtra(Request.EXTRA_OCCURRENCE, request.getOccurrence());
            ids.add(intent.getAction());
            intents.add(new Pair<Date, Intent>(date, intent));
        }
        while (request.moveNext());
        if (intents.isEmpty()) {
            unpersist();
            return;
        }
        persist(ids);
        if (!options.isInfiniteTrigger()) {
            Intent last = intents.get(intents.size() - 1).second;
            last.putExtra(Request.EXTRA_LAST, true);
        }
        for (Pair<Date, Intent> pair : intents) {
            Date date = pair.first;
            long time = date.getTime();
            Intent intent = pair.second;
            if (!date.after(new Date()) && trigger(intent, receiver))
                continue;
            PendingIntent pi = PendingIntent.getBroadcast(
                    context, 0, intent, FLAG_CANCEL_CURRENT);
            try {
                switch (options.getPrio()) {
                    case IMPORTANCE_MIN:
                    case IMPORTANCE_LOW:
                        mgr.setExact(RTC, time, pi);
                        break;
                    case IMPORTANCE_MAX:
                    case IMPORTANCE_HIGH:
                        if (SDK_INT >= M) {
                            mgr.setExactAndAllowWhileIdle(RTC_WAKEUP, time, pi);
                        } else {
                            mgr.setExact(RTC, time, pi);
                        }
                        break;
                    default:
                        mgr.setExact(RTC_WAKEUP, time, pi);
                        break;
                }
            } catch (Exception ignore) {
            }
        }
    }
void schedule ( Request request , Class < ? > receiver ) { List < Pair < Date , Intent > > intents = new ArrayList < Pair < Date , Intent > > ( ) ; Set < String > ids = new ArraySet < String > ( ) ; AlarmManager mgr = getAlarmMgr ( ) ; cancelScheduledAlarms ( ) ; do { Date date = request . getTriggerDate ( ) ; if ( date == null ) continue ; Intent intent = new Intent ( context , receiver ) . setAction ( PREF_KEY_ID + request . getIdentifier ( ) ) . putExtra ( Notification . EXTRA_ID , options . getId ( ) ) . putExtra ( Request . EXTRA_OCCURRENCE , request . getOccurrence ( ) ) ; ids . add ( intent . getAction ( ) ) ; intents . add ( new Pair < Date , Intent > ( date , intent ) ) ; } while ( request . moveNext ( ) ) ; if ( intents . isEmpty ( ) ) { unpersist ( ) ; return ; } persist ( ids ) ; if ( ! options . isInfiniteTrigger ( ) ) { Intent last = intents . get ( intents . size ( ) - 1 ) . second ; last . putExtra ( Request . EXTRA_LAST , true ) ; } for ( Pair < Date , Intent > pair : intents ) { Date date = pair . first ; long time = date . getTime ( ) ; Intent intent = pair . second ; if ( ! date . after ( new Date ( ) ) && trigger ( intent , receiver ) ) continue ; PendingIntent pi = PendingIntent . getBroadcast ( context , 0 , intent , FLAG_CANCEL_CURRENT ) ; try { switch ( options . getPrio ( ) ) { case IMPORTANCE_MIN : case IMPORTANCE_LOW : mgr . setExact ( RTC , time , pi ) ; break ; case IMPORTANCE_MAX : case IMPORTANCE_HIGH : if ( SDK_INT >= M ) { mgr . setExactAndAllowWhileIdle ( RTC_WAKEUP , time , pi ) ; } else { mgr . setExact ( RTC , time , pi ) ; } break ; default : mgr . setExact ( RTC_WAKEUP , time , pi ) ; break ; } } catch ( Exception ignore ) { } } }
Schedule the local notification.
Schedule the local notification .
// Samsung devices have a known bug where a 500 alarms limit // can crash the app