AlarmManager setInexactRepeating - 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 setInexactRepeating method.

This code example shows how to use the following methods:setInexactRepeating
        // that will trigger once the minimum time between passive updates has 
        // expired. This is potentially more expensive 
        // than simple passive alarms, however the Receiver will ensure we've 
        // transitioned beyond the minimum time and 
        // distance before initiating a background nearby loction update. 
        this.alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
                System.currentTimeMillis() + minTime, minDistance, pendingIntent);
    } 
} 
7
CodeRank
This code example shows how to use the following methods:setInexactRepeating
import com.commonsware.cwac.wakeful.WakefulIntentService; 
 
public class AppListener implements WakefulIntentService.AlarmListener { 
  public void scheduleAlarms(AlarmManager mgr, PendingIntent pi,
                             Context ctxt) {
    mgr.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                            SystemClock.elapsedRealtime()+60000,
                            AlarmManager.INTERVAL_FIFTEEN_MINUTES, pi);
  } 
 
  public void sendWakefulWork(Context ctxt) {
    WakefulIntentService.sendWakefulWork(ctxt, AppService.class);
  } 
 
  public long getMaxAge() { 
    return(AlarmManager.INTERVAL_FIFTEEN_MINUTES*2);
  } 
} 
6
CodeRank
This code example shows how to use the following methods:setInexactRepeating
        Log.v(TAG, "onReceive on boot");
        AlarmManager alarmer = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, new Intent(context,
                OnAlarmReceiver.class), 0); 
 
        alarmer.setInexactRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime() + 60000, AlarmManager.INTERVAL_HALF_HOUR,
                pendingIntent);
 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:setInexactRepeating
		// Start 30 seconds after boot completed 
		cal.add(Calendar.SECOND, 30);
		// 
		// Fetch every 30 seconds 
		// InexactRepeating allows Android to optimize the energy consumption 
		service.setInexactRepeating(AlarmManager.RTC_WAKEUP,
				cal.getTimeInMillis(), REPEAT_TIME, pending);
 
		// service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 
		// REPEAT_TIME, pending); 
 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:setInexactRepeating
        // initiating a background nearby loction update. 
 
        long currentTime = System.currentTimeMillis();
        long repeatingInterval = settings.getPassiveUpdatesInterval();
        long startingTime = currentTime + repeatingInterval;
        alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, startingTime, repeatingInterval, pendingIntent);
    } 
 
    @Override 
    public void cancelPassiveLocationUpdates(PendingIntent pendingIntent) {
        alarmManager.cancel(pendingIntent);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setInexactRepeating
 
    public static void startSyncingTimer(final Context context) {
        final AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
        final Intent intent = new Intent(context, SyncingReceiver.class);
        final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
        alarmMgr.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis(),
                AlarmManager.INTERVAL_FIFTEEN_MINUTES, pendingIntent);
    } 
 
    private NetworkUtils() { 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:cancel, setInexactRepeating
		boolean perform_updates = prefs.getBoolean("perform_updates", true);
		if (perform_updates) {
			AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
			Intent i = new Intent(context, UpdateCheckerService.class);
			PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
			am.cancel(pi);
			am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + hours*60*60*1000, hours*60*60*1000, pi);
		} 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:setInexactRepeating
				PendingIntent.FLAG_UPDATE_CURRENT);
 
		AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
 
		if (GotsPreferences.isDevelopment()) 
			alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(),
					AlarmManager.INTERVAL_FIFTEEN_MINUTES, actionTODOIntent);
		else { 
			updateTime.set(Calendar.HOUR_OF_DAY, 20);
			alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(),
					AlarmManager.INTERVAL_DAY * 7, actionTODOIntent);
		} 
 
		Intent weatherBroadcastIntent = new Intent(context, WeatherBroadcastReceiver.class);
		PendingIntent weatherUpdateService = PendingIntent.getBroadcast(context, 1, weatherBroadcastIntent,
				PendingIntent.FLAG_UPDATE_CURRENT);
 
		if (GotsPreferences.isDevelopment()) 
			alarms.setInexactRepeating(AlarmManager.RTC_WAKEUP, updateTime.getTimeInMillis(),
					AlarmManager.INTERVAL_FIFTEEN_MINUTES, weatherUpdateService);

5
CodeRank
This code example shows how to use the following methods:setInexactRepeating
		 
		Intent intent = new Intent(context, AlarmReceiver.class);
		PendingIntent operation = PendingIntent.getBroadcast(context, 0, intent, 0);
		 
		//am.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 1000, operation); 
		am.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis(), interval, operation);
	} 
	 
	public void unregister(Context context) {
 
		AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
		 
		Intent intent = new Intent(context, AlarmReceiver.class);
		PendingIntent operation = PendingIntent.getBroadcast(context, 0, intent, 0);
		 
		am.cancel(operation);
 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:cancel, setInexactRepeating
	    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
	    int minutes = prefs.getInt("interval", 1);
	    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
	    Intent i = new Intent(context, NotificationService.class);
	    PendingIntent pi = PendingIntent.getService(context, 0, i, 0);
	    am.cancel(pi);
	    // by my own convention, minutes <= 0 means notifications are disabled 
	    if (minutes > 0) {
	        am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
	            SystemClock.elapsedRealtime() + minutes*60*1000,
	            minutes*60*1000, pi);
	    } 
	} 
 
} 
5
CodeRank

Related AlarmManager setInexactRepeating Questions & Answers:

setInexactRepeating Method Overview
Schedule a repeating alarm that has inexact trigger time requirements; for example, an alarm that repeats every hour, but not necessarily at the top of every hour.
See Code Examples for other Android AlarmManager Methods: