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:info.papdt.blacklight.support.Utility.java
public static void stopServiceAlarm(Context context, Class<?> service) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, service); PendingIntent p = PendingIntent.getService(context, REQUEST_CODE, i, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(p);/* w w w . j ava2s.c o m*/ }
From source file:com.google.android.apps.iosched.calendar.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID);/*from w w w . j a va2 s .c om*/ final long currentTime = System.currentTimeMillis(); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) { return; } // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - TEN_MINUTES_MILLIS; } else { alarmTime = currentTime + alarmOffset; } final Intent alarmIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. alarmIntent.setData(new Uri.Builder().authority(ScheduleContract.CONTENT_AUTHORITY) .path(String.valueOf(sessionStart)).build()); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); alarmIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, PendingIntent.getService(this, 0, alarmIntent, PendingIntent.FLAG_CANCEL_CURRENT)); }
From source file:com.meiste.greg.ptw.WidgetProvider.java
@SuppressLint("NewApi") private void setAlarm(final Context context) { /* No point setting alarm if no widgets */ if (getInstalledWidgets(context).length == 0) return;//from w w w . jav a 2s .c o m final long now = System.currentTimeMillis(); long next = UPDATE_INTERVAL - (now % UPDATE_INTERVAL) - UPDATE_FUDGE; if (next <= 0) { next += UPDATE_INTERVAL; } final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { am.setExact(AlarmManager.RTC, now + next, getAlarmIntent(context)); } else { am.set(AlarmManager.RTC, now + next, getAlarmIntent(context)); } }
From source file:org.andicar.service.UpdateCheckService.java
private void setNextRun() { Calendar cal = Calendar.getInstance(); if (cal.get(Calendar.HOUR_OF_DAY) >= 18) cal.add(Calendar.DAY_OF_YEAR, 1); cal.set(Calendar.HOUR_OF_DAY, 20); cal.set(Calendar.MINUTE, 0);/* w w w. j a v a2 s.c om*/ Intent i = new Intent(this, UpdateCheckService.class); PendingIntent pIntent = PendingIntent.getService(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC, cal.getTimeInMillis(), pIntent); }
From source file:com.android.deskclock.data.TimerModel.java
TimerModel(Context context, SettingsModel settingsModel, NotificationModel notificationModel) { mContext = context;/* w ww . ja va 2 s .c o m*/ mSettingsModel = settingsModel; mNotificationModel = notificationModel; mNotificationManager = NotificationManagerCompat.from(context); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); // Clear caches affected by preferences when preferences change. final SharedPreferences prefs = Utils.getDefaultSharedPreferences(mContext); prefs.registerOnSharedPreferenceChangeListener(mPreferenceListener); // Update stopwatch notification when locale changes. final IntentFilter localeBroadcastFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiver(mLocaleChangedReceiver, localeBroadcastFilter); }
From source file:com.kubotaku.android.code4kyoto5374.util.AlarmService.java
/** * ?/*from ww w. j a v a 2 s . c o m*/ * * @param context * @param garbageType ?? */ public static void cancelAlarm(Context context, final int garbageType) { final Intent intent = createIntent(context, garbageType); final PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); }
From source file:com.sean.takeastand.alarmprocess.UnscheduledRepeatingAlarm.java
private void setAlarm(long triggerTime) { PendingIntent pendingIntent = createPendingIntent(mContext); AlarmManager am = ((AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE)); am.set(AlarmManager.ELAPSED_REALTIME, triggerTime, pendingIntent); }
From source file:com.onyx.deskclock.deskclock.data.TimerModel.java
TimerModel(Context context, SettingsModel settingsModel, NotificationModel notificationModel) { mContext = context;/*from w ww . j av a2 s. c o m*/ mSettingsModel = settingsModel; mNotificationModel = notificationModel; mNotificationManager = NotificationManagerCompat.from(context); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); // Clear caches affected by preferences when preferences change. final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); prefs.registerOnSharedPreferenceChangeListener(mPreferenceListener); // Update stopwatch notification when locale changes. final IntentFilter localeBroadcastFilter = new IntentFilter(Intent.ACTION_LOCALE_CHANGED); mContext.registerReceiver(mLocaleChangedReceiver, localeBroadcastFilter); }
From source file:com.example.ireviewr.MainActivity.java
private void setUpReceiver() { sync = new SyncReceiver(); // Retrieve a PendingIntent that will perform a broadcast Intent alarmIntent = new Intent(this, SyncService.class); pendingIntent = PendingIntent.getService(this, 0, alarmIntent, 0); manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); consultPreferences();/*from w w w. java 2s .co m*/ }
From source file:com.conferenceengineer.android.iosched.service.SessionAlarmService.java
private void scheduleAlarm(final long sessionStart, final long sessionEnd, final long alarmOffset) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(NOTIFICATION_ID);/*from w w w.j av a 2s. c o m*/ final long currentTime = UIUtils.getCurrentTime(this); // If the session is already started, do not schedule system notification. if (currentTime > sessionStart) return; // By default, sets alarm to go off at 10 minutes before session start time. If alarm // offset is provided, alarm is set to go off by that much time from now. long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionStart - MILLI_TEN_MINUTES; } else { alarmTime = currentTime + alarmOffset; } final Intent notifIntent = new Intent(ACTION_NOTIFY_SESSION, null, this, SessionAlarmService.class); // Setting data to ensure intent's uniqueness for different session start times. notifIntent.setData(new Uri.Builder().authority("com.conferenceengineer.android.iosched") .path(String.valueOf(sessionStart)).build()); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_START, sessionStart); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_END, sessionEnd); notifIntent.putExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, alarmOffset); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); // Schedule an alarm to be fired to notify user of added sessions are about to begin. am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }