List of usage examples for android.app AlarmManager INTERVAL_HOUR
long INTERVAL_HOUR
To view the source code for android.app AlarmManager INTERVAL_HOUR.
Click Source Link
From source file:de.geeksfactory.opacclient.reminder.SyncAccountService.java
@Override protected void doWakefulWork(Intent intent) { if (BuildConfig.DEBUG) Log.i(NAME, "SyncAccountService started"); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (!sp.getBoolean(SyncAccountAlarmListener.PREF_SYNC_SERVICE, false)) { if (BuildConfig.DEBUG) Log.i(NAME, "notifications are disabled"); return;//from w ww .j av a 2 s . co m } ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); if (networkInfo != null) { if (!sp.getBoolean("notification_service_wifionly", false) || networkInfo.getType() == ConnectivityManager.TYPE_WIFI || networkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) { syncAccounts(); } else { failed = true; } } else { failed = true; } if (BuildConfig.DEBUG) { Log.i(NAME, "SyncAccountService finished " + (failed ? " with errors" : " " + "successfully")); } long previousPeriod = sp.getLong(SyncAccountAlarmListener.PREF_SYNC_INTERVAL, 0); long newPeriod = failed ? AlarmManager.INTERVAL_HOUR : AlarmManager.INTERVAL_HALF_DAY; if (previousPeriod != newPeriod) { sp.edit().putLong(SyncAccountAlarmListener.PREF_SYNC_INTERVAL, newPeriod).apply(); WakefulIntentService.cancelAlarms(this); WakefulIntentService.scheduleAlarms(SyncAccountAlarmListener.withOnePeriodBeforeStart(), this); } }
From source file:com.jtechme.apphub.UpdateService.java
public static void schedule(Context ctx) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String sint = prefs.getString(Preferences.PREF_UPD_INTERVAL, "0"); int interval = Integer.parseInt(sint); Intent intent = new Intent(ctx, UpdateService.class); PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0); AlarmManager alarm = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE); alarm.cancel(pending);/*from w w w. j a v a 2s. c o m*/ if (interval > 0) { alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, AlarmManager.INTERVAL_HOUR, pending); Utils.debugLog(TAG, "Update scheduler alarm set"); } else { Utils.debugLog(TAG, "Update scheduler alarm not set"); } }
From source file:com.Candy.ota.settings.Settings.java
private int getUpdateInterval() { SharedPreferences prefs = getSharedPreferences(LAST_INTERVAL, 0); long value = prefs.getLong(LAST_INTERVAL, 0); int settingsValue; if (value == AlarmManager.INTERVAL_DAY) { settingsValue = 0;/* w ww. j a v a 2 s . c o m*/ } else if (value == AlarmManager.INTERVAL_HALF_DAY || value == 0) { settingsValue = 1; } else if (value == AlarmManager.INTERVAL_HOUR) { settingsValue = 2; } else { settingsValue = 3; } return settingsValue; }
From source file:com.jerrellmardis.amphitheatre.util.Utils.java
public static void scheduleLibraryUpdateService(Context context) { Log.d("amp:Utils", "Checking if alarm is already set: " + isAlarmAlreadySet(context, LibraryUpdateService.class)); //And now/*from w w w . j av a 2s . c om*/ Log.d("amp:Utils", "Start rechecking the library"); Intent intent = new Intent(context, LibraryUpdateService.class); intent.putExtra("ALARM", true); /*context.startService(intent);*/ if (isAlarmAlreadySet(context, LibraryUpdateService.class)) return; AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); //Intent intent = ... PendingIntent alarmIntent = PendingIntent.getService(context, LIBRARY_UPDATE_REQUEST_CODE, intent, 0); alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_HALF_HOUR, AlarmManager.INTERVAL_HOUR * 3, //Every three hours seems sufficient alarmIntent); }
From source file:com.near.chimerarevo.fragments.SettingsFragment.java
private void setAlarm(int sel, boolean isEnabled) { Intent intent = new Intent(getActivity().getApplicationContext(), NewsService.class); PendingIntent pintent = PendingIntent.getService(getActivity().getApplicationContext(), 0, intent, 0); AlarmManager alarm = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarm.cancel(pintent);/* w ww .ja v a 2s. c o m*/ if (isEnabled) { long delay; switch (sel) { case 0: delay = AlarmManager.INTERVAL_FIFTEEN_MINUTES; break; case 1: delay = AlarmManager.INTERVAL_HALF_HOUR; break; case 2: delay = AlarmManager.INTERVAL_HOUR; break; case 3: delay = 2 * AlarmManager.INTERVAL_HOUR; break; case 4: delay = 3 * AlarmManager.INTERVAL_HOUR; break; case 5: delay = 6 * AlarmManager.INTERVAL_HOUR; break; case 6: delay = AlarmManager.INTERVAL_HALF_DAY; break; case 7: delay = AlarmManager.INTERVAL_DAY; break; default: delay = AlarmManager.INTERVAL_HOUR; break; } alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.uptimeMillis(), delay, pintent); } }
From source file:de.hero.vertretungsplan.MainActivity.java
public static void setNewAlarm(Context context, boolean set, String interval) { Intent i = new Intent(context, de.hero.vertretungsplan.CheckForUpdates.class); PendingIntent pi = PendingIntent.getService(context, 0, i, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi); // cancel any existing alarms Log.d("MainActivity", "cancelAlarm"); if (set) {//from w w w. j a v a 2 s. c o m long lngInterval; switch (interval) { case "1/2": lngInterval = AlarmManager.INTERVAL_HALF_HOUR; break; case "1": lngInterval = AlarmManager.INTERVAL_HOUR; break; case "6": lngInterval = AlarmManager.INTERVAL_HALF_DAY / 2; break; case "3": default: lngInterval = AlarmManager.INTERVAL_HOUR * 3; break; } Log.d("MainActivity", "setAlarm " + interval + " Stunden"); am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR / 3, lngInterval, pi); // For debugging after 10 seconds // am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, // SystemClock.elapsedRealtime() + 25000 , // AlarmManager.INTERVAL_HOUR , pi); } }
From source file:com.adguard.android.service.FilterServiceImpl.java
@Override public void scheduleFiltersUpdate() { Intent alarmIntent = new Intent(AlarmReceiver.UPDATE_FILTER_ACTION); boolean isRunning = PendingIntent.getBroadcast(context, 0, alarmIntent, PendingIntent.FLAG_NO_CREATE) != null; if (!isRunning) { LOG.info("Starting scheduler of filters updating"); PendingIntent broadcastIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, UPDATE_INITIAL_PERIOD, AlarmManager.INTERVAL_HOUR, broadcastIntent);//from ww w . j a v a 2 s . c om } else { LOG.info("Filters update is running"); } }
From source file:org.roman.findme.MainActivity.java
void startLocationService() { // Intent intent = new Intent(this, AndroidLocationServices.class); // startService(intent); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 1253, intent, PendingIntent.FLAG_CANCEL_CURRENT); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.cancel(pendingIntent);//from ww w . j av a 2 s.c o m alarm.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_HOUR, pendingIntent); }
From source file:com.near.chimerarevo.activities.MainActivity.java
@Override public void onDestroy() { super.onDestroy(); if (ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().clearDiskCache(); ImageLoader.getInstance().clearMemoryCache(); }/*from w w w . j a va 2 s . co m*/ if (mHelper != null) mHelper.dispose(); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("news_search_pref", true)) { Intent intent = new Intent(getApplicationContext(), NewsService.class); PendingIntent pintent = PendingIntent.getService(getApplicationContext(), 0, intent, 0); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.cancel(pintent); long delay; int sel = Integer.parseInt( PreferenceManager.getDefaultSharedPreferences(this).getString("notification_delay_pref", "0")); switch (sel) { case 0: delay = AlarmManager.INTERVAL_FIFTEEN_MINUTES; break; case 1: delay = AlarmManager.INTERVAL_HALF_HOUR; break; case 2: delay = AlarmManager.INTERVAL_HOUR; break; case 3: delay = 2 * AlarmManager.INTERVAL_HOUR; break; case 4: delay = 3 * AlarmManager.INTERVAL_HOUR; break; case 5: delay = 6 * AlarmManager.INTERVAL_HOUR; break; case 6: delay = AlarmManager.INTERVAL_HALF_DAY; break; case 7: delay = AlarmManager.INTERVAL_DAY; break; default: delay = AlarmManager.INTERVAL_HOUR; break; } alarm.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.uptimeMillis(), delay, pintent); } }
From source file:id.ridon.keude.UpdateService.java
public static void schedule(Context ctx) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String sint = prefs.getString(Preferences.PREF_UPD_INTERVAL, "0"); int interval = Integer.parseInt(sint); Intent intent = new Intent(ctx, UpdateService.class); PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0); AlarmManager alarm = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE); alarm.cancel(pending);/*from w ww . ja v a 2 s . c o m*/ if (interval > 0) { alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, AlarmManager.INTERVAL_HOUR, pending); Log.d("Keude", "Update scheduler alarm set"); } else { Log.d("Keude", "Update scheduler alarm not set"); } }