List of usage examples for android.content Context ALARM_SERVICE
String ALARM_SERVICE
To view the source code for android.content Context ALARM_SERVICE.
Click Source Link
From source file:edu.uri.egr.hermes.wrappers.ScheduleWrapper.java
public ScheduleWrapper(Hermes hermes) { this.hermes = hermes; this.alarmManager = (AlarmManager) hermes.getContext().getSystemService(Context.ALARM_SERVICE); }
From source file:cat.wuyingren.whatsannoy.utils.SystemUtils.java
public static void createAlarm(Context context, Schedule schedule) { Log.w("UTILS", "createAlarm() / Scheduled: " + schedule.getId()); Intent alarmIntent = new Intent(context, Alarm.class); alarmIntent.putExtra(Alarm.PREF_ALARM_ID, schedule.getId()); PendingIntent pi = PendingIntent.getBroadcast(context, SystemUtils.safeLongToInt(schedule.getId()), alarmIntent, 0);//from w ww. j av a2 s. c om AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmMgr.set(AlarmManager.RTC_WAKEUP, schedule.getDate(), pi); }
From source file:com.meiste.greg.ptw.QuestionAlarm.java
@SuppressLint("NewApi") public static void set(final Context context) { // Get next points race: allow in progress Race race = Race.getNext(context, false, true); if (race == null) return;// w ww. ja v a 2s . co m // Check if user was already reminded of in progress race if (Util.getState(context).getInt(LAST_REMIND, -1) >= race.getId()) { // Get next points race: do not allow in progress race = Race.getNext(context, false, false); if (race == null) return; } if (!alarm_set) { Util.log("Setting question alarm for race " + race.getId()); final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); final Intent intent = new Intent(context, QuestionAlarm.class); intent.putExtra(RACE_ID, race.getId()); final PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { am.setExact(AlarmManager.RTC_WAKEUP, race.getQuestionTimestamp(), pendingIntent); } else { am.set(AlarmManager.RTC_WAKEUP, race.getQuestionTimestamp(), pendingIntent); } alarm_set = true; } else { Util.log("Not setting question alarm: alarm_set=" + alarm_set); } }
From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java
public static void silenter(Context c, long dur) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c); boolean silent = "silent".equals(prefs.getString("silenterType", "silent")); AudioManager aum = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE); int ringermode = aum.getRingerMode(); if ((ringermode != AudioManager.RINGER_MODE_SILENT) && ((ringermode != AudioManager.RINGER_MODE_VIBRATE) || silent)) { AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); Intent i;//from www.j a v a 2 s. c om if (ringermode == AudioManager.RINGER_MODE_VIBRATE) { i = new Intent(c, setVibrate.class); } else { i = new Intent(c, setNormal.class); } PendingIntent service = PendingIntent.getBroadcast(c, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 60 * dur), service); if (PermissionUtils.get(c).pNotPolicy) aum.setRingerMode(silent ? AudioManager.RINGER_MODE_SILENT : AudioManager.RINGER_MODE_VIBRATE); } }
From source file:com.google.android.apps.dashclock.PeriodicExtensionRefreshReceiver.java
/** * Sets the refresh schedule if one isn't set already. *//* www . ja v a 2 s . c o m*/ public static void updateExtensionsAndEnsurePeriodicRefresh(final Context context) { LOGD(TAG, "updateExtensionsAndEnsurePeriodicRefresh"); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); // Update all extensions now. context.startService(getUpdateAllExtensionsIntent(context, DashClockExtension.UPDATE_REASON_MANUAL)); // Schedule an alarm for every 30 minutes; it will not wake up the device; // it will be handled only once the device is awake. The first time that this // alarm can go off is in 15 minutes, and the latest time it will go off is // 45 minutes from now. PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(context, PeriodicExtensionRefreshReceiver.class).setAction(ACTION_PERIODIC_ALARM), PendingIntent.FLAG_UPDATE_CURRENT); am.cancel(pi); am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 15 * MINUTES_MILLIS, AlarmManager.INTERVAL_HALF_HOUR, pi); }
From source file:ch.fixme.status.Widget.java
public void onReceive(Context ctxt, Intent intent) { String action = intent.getAction(); if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) { // Remove widget alarm int widgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); PendingIntent pi = PendingIntent.getService(ctxt, widgetId, getIntent(ctxt, widgetId), 0); AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE); am.cancel(pi);/*w w w .j a va 2 s.c o m*/ // remove preference SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt); Editor edit = prefs.edit(); edit.remove(Main.PREF_API_URL_WIDGET + widgetId); edit.remove(Main.PREF_INIT_WIDGET + widgetId); edit.remove(Main.PREF_LAST_WIDGET + widgetId); edit.remove(Main.PREF_FORCE_WIDGET + widgetId); edit.commit(); // Log.i(Main.TAG, "Remove widget alarm for id=" + widgetId); } else if (intent.hasExtra(WIDGET_IDS) && AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) { int[] ids = intent.getExtras().getIntArray(WIDGET_IDS); onUpdate(ctxt, AppWidgetManager.getInstance(ctxt), ids); } else super.onReceive(ctxt, intent); }
From source file:com.commonsware.android.deepbg.PollReceiver.java
@Override public void onReceive(Context ctxt, Intent i) { Log.d(getClass().getSimpleName(), "Received alarm broadcast"); boolean isDownload = i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false); startWakefulService(ctxt,/*from w w w . j a v a2 s . c o m*/ new Intent(ctxt, DemoScheduledService.class).putExtra(EXTRA_IS_DOWNLOAD, isDownload)); long period = i.getLongExtra(EXTRA_PERIOD, -1); if (period > 0) { scheduleExactAlarm(ctxt, (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE), period, isDownload); } }
From source file:org.chromium.ChromeAlarms.java
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); if (ChromeAlarms.webView == null && cordova.getActivity().getIntent().hasExtra(ALARM_NAME_LABEL)) { cordova.getActivity().moveTaskToBack(true); }//ww w .j a v a 2 s . com ChromeAlarms.webView = webView; alarmManager = (AlarmManager) cordova.getActivity().getSystemService(Context.ALARM_SERVICE); }
From source file:org.dodgybits.shuffle.android.server.sync.SyncAlarmService.java
@Override protected void onHandleIntent(Intent intent) { long lastSyncDate = Preferences.getLastSyncLocalDate(this); long nextSyncDate = Math.max(System.currentTimeMillis() + 5000L, lastSyncDate + SYNC_PERIOD); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Next sync at " + new Date(nextSyncDate)); }//from w ww. j a v a2s .c o m AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent syncIntent = new Intent(this, SyncAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.RTC, nextSyncDate, SYNC_PERIOD, pendingIntent); // Release the wake lock provided by the WakefulBroadcastReceiver WakefulBroadcastReceiver.completeWakefulIntent(intent); }
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); }