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:com.android.anton.pushnotificationwithgcm.GCMUtil.MyGcmListenerService.java
@Override public void onTaskRemoved(Intent rootIntent) { Intent restartServiceIntent = new Intent(getApplicationContext(), this.getClass()); restartServiceIntent.setPackage(getPackageName()); PendingIntent restartServicePendingIntent = PendingIntent.getService(getApplicationContext(), 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent); super.onTaskRemoved(rootIntent); }
From source file:com.kubotaku.android.code4kyoto5374.util.AlarmService.java
@TargetApi(Build.VERSION_CODES.M) private static void setupAlarmNew(Context context, PendingIntent intent, final long triggerAtMillis) { final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setAndAllowWhileIdle(AlarmManager.RTC, triggerAtMillis, intent); }
From source file:com.rickendirk.rsgwijzigingen.ZoekService.java
private void setAlarmIn20Min() { Intent zoekIntent = new Intent(this, ZoekService.class); zoekIntent.putExtra("isAchtergrond", true); zoekIntent.addCategory("GeenWifiHerhaling"); //Categorie om andere intents cancelen te voorkomen PendingIntent pendingIntent = PendingIntent.getService(this, 3, zoekIntent, PendingIntent.FLAG_ONE_SHOT); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Long in20Min = SystemClock.elapsedRealtime() + 1200000; //20Min in milisec. manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, in20Min, pendingIntent); Log.i(TAG, "Nieuw alarm gezet in 20 min"); }
From source file:com.meiste.greg.ptw.WidgetProvider.java
@Override public void onDisabled(final Context context) { Util.log("WidgetProvider.onDisabled"); final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(getAlarmIntent(context));/*from www . ja v a2s . c o m*/ Util.getState(context).edit().putBoolean(WIDGET_STATE, false).apply(); Analytics.trackEvent(context, "Widget", "state", "disabled"); }
From source file:com.battlelancer.seriesguide.util.Utils.java
/** * Run the notification service delayed by a minute to display and (re)schedule upcoming episode * alarms./* w w w .ja v a2s. co m*/ */ public static void runNotificationServiceDelayed(Context context) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, OnAlarmReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1 * DateUtils.MINUTE_IN_MILLIS, pi); }
From source file:at.jclehner.rxdroid.NotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent == null) return;//from ww w .ja va 2 s . c om Settings.init(); Database.init(); final boolean isAlarmRepetition = intent.getBooleanExtra(EXTRA_IS_ALARM_REPETITION, false); final int doseTime = intent.getIntExtra(EXTRA_DOSE_TIME, Schedule.TIME_INVALID); if (doseTime != Schedule.TIME_INVALID) { if (!isAlarmRepetition) { final Date date = (Date) intent.getSerializableExtra(EXTRA_DATE); final boolean isDoseTimeEnd = intent.getBooleanExtra(EXTRA_IS_DOSE_TIME_END, false); final String eventName = isDoseTimeEnd ? "onDoseTimeEnd" : "onDoseTimeBegin"; sEventMgr.post(eventName, EVENT_HANDLER_ARG_TYPES, date, doseTime); } } mContext = context; mAlarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mDoPostSilent = intent.getBooleanExtra(EXTRA_SILENT, false); mForceUpdate = isAlarmRepetition ? true : intent.getBooleanExtra(EXTRA_FORCE_UPDATE, false); mAllDrugs = Database.getAll(Drug.class); rescheduleAlarms(); updateCurrentNotifications(); }
From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java
@SuppressWarnings("deprecation") @Override/*from w ww . j a va 2s . co m*/ public void onCreate() { created = true; settings = new RecSettings(); settings.load(getApplicationContext(), PreferenceManager.getDefaultSharedPreferences(getApplicationContext())); createNotification(NOTIFICATION_ID); if (settings.isSchedRecEnabled() && settings.getSchedRecTime() > System.currentTimeMillis() + 10000) { AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(getApplicationContext(), ScheduleReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0); alarmMgr.set(AlarmManager.RTC_WAKEUP, settings.getSchedRecTime(), alarmIntent); stopSelf(); return; } // Create new SurfaceView, set its size to 1x1, move // it to the top left corner and set this service as a callback WindowManager winMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE); surfaceView = new SurfaceView(this); // deprecated setting, but required on Android versions prior to 3.0 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); surfaceView.getHolder().addCallback(this); LayoutParams layoutParams = new WindowManager.LayoutParams(1, 1, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); layoutParams.gravity = Gravity.LEFT | Gravity.TOP; winMgr.addView(surfaceView, layoutParams); PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); wakeLock.setReferenceCounted(false); wakeLock.acquire(); }
From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java
private void cancelAlarm(final long matchId, final long matchStart) { final long currentTime = TimeUtils.getUTCTime(); LOGD(TAG, "Unscheduling Alarm"); if (currentTime > matchStart) { LOGD(TAG, "wat."); return;/*from w w w .j a va2s . c o m*/ } final Intent notifIntent = new Intent(ACTION_NOTIFY_MATCH, null, this, ReminderAlarmService.class); notifIntent.setData( new Uri.Builder().authority("ca.zadrox.dota2esportticker").path(String.valueOf(matchId)).build()); notifIntent.putExtra(ReminderAlarmService.EXTRA_MATCH_ID, matchId); notifIntent.putExtra(ReminderAlarmService.EXTRA_MATCH_START, matchStart); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); final AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); am.cancel(pi); }
From source file:net.naonedbus.appwidget.HoraireWidgetProvider.java
/** * Programmer le rafraichissement des widgets. * // w w w .j a v a 2 s . c om * @param context * @param timestamp */ private synchronized void scheduleUpdate(final Context context, final long timestamp) { final long now = new DateTime().getMillis(); final long triggerTimestamp = new DateTime(timestamp).plusMinutes(1).getMillis(); if (sNextTimestamp < now || triggerTimestamp < sNextTimestamp) { sNextTimestamp = triggerTimestamp; final AlarmManager m = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); if (sPendingIntent != null) { m.cancel(sPendingIntent); if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "\tAnnulation de la prcdente alarme."); } final Intent intent = new Intent(ACTION_APPWIDGET_UPDATE); sPendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0); m.set(AlarmManager.RTC, sNextTimestamp, sPendingIntent); if (DBG) Log.i(LOG_TAG, Integer.toHexString(hashCode()) + " - " + "Programmation de l'alarme : " + new DateTime(sNextTimestamp).toString()); } }
From source file:com.kubotaku.android.code4kyoto5374.util.AlarmService.java
private static void setupAlarmOld(Context context, PendingIntent intent, final long triggerAtMillis) { final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC, triggerAtMillis, intent); }