AlarmManager setRepeating - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for AlarmManager setRepeating method.

This code example shows how to use the following methods:setRepeating
This code example shows how to use the following methods:cancel, setRepeating
 
        Log.i("Astrid", "Autosync set for " + offset / 1000 //$NON-NLS-1$ //$NON-NLS-2$
            + " seconds repeating every " + syncFrequencySeconds); //$NON-NLS-1$
 
        // cancel all existing 
        am.cancel(pendingIntent);
 
        // schedule new 
        am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + offset,
                interval, pendingIntent);
    } 
 
 
    /** 
     * Removes repeating alarm for auto-synchronization 
     */ 
    private void unscheduleService(Context context) {
        AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        PendingIntent pendingIntent = PendingIntent.getService(context, getSyncUtilities().getSyncIntervalKey(),
                createAlarmIntent(context), PendingIntent.FLAG_UPDATE_CURRENT);
7
CodeRank
This code example shows how to use the following methods:cancel, setRepeating
    public static void resetAlarm(Context context, long interval) {
        // Create an IntentSender that will launch our service, to be scheduled 
        // with the alarm manager. 
        PendingIntent alarmSender = PendingIntent.getService(context, 0, new Intent(context, EnvelopeService.class), 0);
        AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE);
        am.cancel(alarmSender);
        if (interval != 0)
        	am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), interval, alarmSender);
    } 
} 
 
7
CodeRank
This code example shows how to use the following methods:cancel, setRepeating
					this.appSettings.getString("autoSyncInterval", "1800000"),
					10); 
 
			this.alarmIntent = PendingIntent.getService(appInst, 0, new Intent(
					this, SyncService.class), 0);
			alarmManager.setRepeating(AlarmManager.RTC,
					System.currentTimeMillis() + interval, interval,
					alarmIntent);
 
			this.alarmScheduled = true;
		} 
	} 
 
	private void unsetAlarm() { 
		if (this.alarmScheduled) {
			this.alarmManager.cancel(this.alarmIntent);
			this.alarmScheduled = false;
		} 
	} 
 
	private void resetAlarm() { 
7
CodeRank
This code example shows how to use the following methods:setRepeating
This code example shows how to use the following methods:cancel, set, setRepeating
 
		if (command.contains("Start Alarm")) {
			alarmManager.set(AlarmManager.RTC_WAKEUP, time, pi);
		} else if (command.contains("Stop Alarm")) {
			pi.cancel(); 					// Cancel the pendingIntent.
			alarmManager.cancel(pi); 		// Cancel the alarm.
			 
			// If more times with a timeReminder exist, start a new alarm. 
			if (time != 0) alarmManager.set(AlarmManager.RTC_WAKEUP, time, pi);
		} else 
			Log.e("AlarmManagerService", "Command contained unknown value");
	} 
 
	/** 
	 * Method for starting or stopping the position alarm. 
	 * @param command decides whether to start or stop the alarm. 
	 */ 
	private void positionAlarm(String command) {
		// Let the receiver know its a position-alarm. 
		alarmReceiverIntent.putExtra("alarmType", "position");

7
CodeRank
This code example shows how to use the following methods:setRepeating
This code example shows how to use the following methods:setRepeating
This code example shows how to use the following methods:setRepeating
This code example shows how to use the following methods:setRepeating
	private void setUpdateAlarm() { 
		Intent intent = new Intent(this, TimeclockService.class);
		intent.putExtra("action", TIMECLOCK_UPDATE);
		this.updateIntent = PendingIntent.getService(appInst, 1,
				intent, 0);
		alarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis()
				+ DateUtils.MINUTE_IN_MILLIS, DateUtils.MINUTE_IN_MILLIS, updateIntent);
	} 
	 
	private void setTimeoutAlarm(int hour, int minute) {
		if(hour <= 0 && minute <= 0)
			return; 
		 
		long time = (hour * DateUtils.HOUR_IN_MILLIS)
				+ (minute * DateUtils.MINUTE_IN_MILLIS);
		 
		Intent intent = new Intent(this, TimeclockService.class);
		intent.putExtra("action", TIMECLOCK_TIMEOUT);
		this.timeoutIntent = PendingIntent.getService(appInst, 2,
				intent, 0);
6
CodeRank

Related AlarmManager setRepeating Questions & Answers:

setRepeating Method Overview
Schedule a repeating alarm.
See Code Examples for other Android AlarmManager Methods: