List of usage examples for android.app AlarmManager INTERVAL_FIFTEEN_MINUTES
long INTERVAL_FIFTEEN_MINUTES
To view the source code for android.app AlarmManager INTERVAL_FIFTEEN_MINUTES.
Click Source Link
From source file:com.licenta.android.licenseapp.alarm.AlarmReceiver.java
public static void setAlarm(Context context) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); /*// w ww.jav a2 s .c o m * If you don't have precise time requirements, use an inexact repeating alarm * the minimize the drain on the device battery. * * The call below specifies the alarm type, the trigger time, the interval at * which the alarm is fired, and the alarm's associated PendingIntent. * It uses the alarm type RTC_WAKEUP ("Real Time Clock" wake up), which wakes up * the device and triggers the alarm according to the time of the device's clock. * * Alternatively, you can use the alarm type ELAPSED_REALTIME_WAKEUP to trigger * an alarm based on how much time has elapsed since the device was booted. This * is the preferred choice if your alarm is based on elapsed time--for example, if * you simply want your alarm to fire every 60 minutes. You only need to use * RTC_WAKEUP if you want your alarm to fire at a particular date/time. Remember * that clock-based time may not translate well to other locales, and that your * app's behavior could be affected by the user changing the device's time setting. * */ // Wake up the device to fire the alarm in 30 minutes, and every 30 minutes // after that. long intervalMillis; String intervalVal = prefs.getString("repeat_interval", "0"); switch (intervalVal) { case "15": intervalMillis = AlarmManager.INTERVAL_FIFTEEN_MINUTES; break; case "30": intervalMillis = AlarmManager.INTERVAL_HALF_HOUR; break; case "60": intervalMillis = AlarmManager.INTERVAL_HOUR; break; default: intervalMillis = 0; break; } // for testing intervalMillis = 6000; alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + intervalMillis, intervalMillis, alarmIntent); prefs.edit().putBoolean(Constants.PREF_KEY_IS_ALARM_ON, true).apply(); Log.d(context.getClass().getName(), "Alarm started"); }
From source file:com.numenta.core.service.AlarmReceiver.java
public void startAlarm(Context context) { _alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); _alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); // Tries to wakeup the phone every 15 minutes to synchronize the data. // The 15 minutes interval was chosen because this way this be alarm will be phase-aligned // with other alarms to reduce the number of wake ups. See AlarmManager#setInexactRepeating _alarmMgr.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, _alarmIntent); }
From source file:com.footprint.cordova.plugin.localnotification.Options.java
/** * Parses the given properties// w ww .j a v a 2 s .com */ public Options parse(JSONObject options) { String repeat = options.optString("repeat"); this.options = options; if (repeat.equalsIgnoreCase("secondly")) { interval = 1000; } if (repeat.equalsIgnoreCase("minutely")) { interval = AlarmManager.INTERVAL_FIFTEEN_MINUTES / 15; } if (repeat.equalsIgnoreCase("hourly")) { interval = AlarmManager.INTERVAL_HOUR; } if (repeat.equalsIgnoreCase("daily")) { interval = AlarmManager.INTERVAL_DAY; } else if (repeat.equalsIgnoreCase("weekly")) { interval = AlarmManager.INTERVAL_DAY * 7; } else if (repeat.equalsIgnoreCase("monthly")) { interval = AlarmManager.INTERVAL_DAY * 31; // 31 days } else if (repeat.equalsIgnoreCase("yearly")) { interval = AlarmManager.INTERVAL_DAY * 365; } else { try { interval = Integer.parseInt(repeat) * 60000; } catch (Exception e) { } ; } return this; }
From source file:com.commontime.plugin.notification.notification.Options.java
/** * Parse repeat interval.//from www . j av a 2 s . c om */ private void parseInterval() { String every = options.optString("every").toLowerCase(); if (every.isEmpty()) { interval = 0; } else if (every.equals("second")) { interval = 1000; } else if (every.equals("minute")) { interval = AlarmManager.INTERVAL_FIFTEEN_MINUTES / 15; } else if (every.equals("hour")) { interval = AlarmManager.INTERVAL_HOUR; } else if (every.equals("day")) { interval = AlarmManager.INTERVAL_DAY; } else if (every.equals("week")) { interval = AlarmManager.INTERVAL_DAY * 7; } else if (every.equals("month")) { interval = AlarmManager.INTERVAL_DAY * 31; } else if (every.equals("year")) { interval = AlarmManager.INTERVAL_DAY * 365; } else { try { interval = Integer.parseInt(every) * 60000; } catch (Exception e) { e.printStackTrace(); } } }
From source file:de.wikilab.android.friendica01.Max.java
public static void runTimer(Context c) { Log.i("Friendica", "try runTimer"); if (piTimerNotifications != null) return;// ww w.j a va 2 s . c o m AlarmManager a = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); piTimerNotifications = PendingIntent.getService(c, 1, new Intent(c, NotificationCheckerService.class), 0); a.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, 0, AlarmManager.INTERVAL_FIFTEEN_MINUTES, piTimerNotifications); Toast.makeText(c, "Friendica: Notif. check timer run", Toast.LENGTH_SHORT).show(); Log.i("Friendica", "done runTimer"); }
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);//from w ww. j a va 2s. c om 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:com.svpino.longhorn.activities.DashboardActivity.java
@Override protected void onStart() { super.onStart(); DataProvider.startStockQuoteCollectorService(this, null); ((AlarmManager) getSystemService(Context.ALARM_SERVICE)).setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis(), AlarmManager.INTERVAL_FIFTEEN_MINUTES, Extensions.createPendingIntent(this, Constants.SCHEDULE_AUTOMATIC)); }
From source file:de.schildbach.wallet.service.BlockchainService.java
public static void scheduleStart(final WalletApplication application) { final Configuration config = application.getConfiguration(); final long lastUsedAgo = config.getLastUsedAgo(); // apply some backoff final long alarmInterval; if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_JUST_MS) alarmInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES; else if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_RECENTLY_MS) alarmInterval = AlarmManager.INTERVAL_HALF_DAY; else/*from w ww.j a va 2 s . c om*/ alarmInterval = AlarmManager.INTERVAL_DAY; log.info("last used {} minutes ago, rescheduling blockchain sync in roughly {} minutes", lastUsedAgo / DateUtils.MINUTE_IN_MILLIS, alarmInterval / DateUtils.MINUTE_IN_MILLIS); final AlarmManager alarmManager = (AlarmManager) application.getSystemService(Context.ALARM_SERVICE); final PendingIntent alarmIntent = PendingIntent.getService(application, 0, new Intent(application, BlockchainService.class), 0); alarmManager.cancel(alarmIntent); // workaround for no inexact set() before KitKat final long now = System.currentTimeMillis(); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, now + alarmInterval, AlarmManager.INTERVAL_DAY, alarmIntent); }
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 v a 2 s.c om*/ 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:org.ametro.app.ApplicationEx.java
public void changeAlarmReceiverState(boolean enabled) { AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); Intent intent = new Intent(this, AlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); alarmManager.cancel(pendingIntent);// www. ja v a 2 s . c o m if (enabled) { long interval = (GlobalSettings.getUpdatePeriod(this) == 900) ? AlarmManager.INTERVAL_FIFTEEN_MINUTES : AlarmManager.INTERVAL_DAY; alarmManager.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis() + 1000 * 60 * 2, interval, pendingIntent); } }