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.gsma.rcs.ri.RcsServiceNotifManager.java
@Override public void onCreate() { if (LogUtils.isActive) { Log.d(LOGTAG, "Service started"); }//www .ja v a 2 s . c o m mCtx = this; mCnxIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_API_CONNECT), 0); mAlarmManager = (AlarmManager) mCtx.getSystemService(Context.ALARM_SERVICE); notifyImsUnregistered(RcsServiceRegistration.ReasonCode.UNSPECIFIED); mStartupEventReceiver = new RcsServiceStartupListener(); registerReceiver(mStartupEventReceiver, new IntentFilter(RcsService.ACTION_SERVICE_UP)); /* Register the broadcast receiver to pool periodically the API connections */ registerReceiver(new ReceiveTimerToReConnectApi(), new IntentFilter(ACTION_API_CONNECT)); mRetryCount = 0; connectToService(this); }
From source file:de.geeksfactory.opacclient.reminder.ReminderCheckService.java
@Override public int onStartCommand(Intent intent, int flags, int startid) { if (ACTION_SNOOZE.equals(intent.getAction())) { Intent i = new Intent(ReminderCheckService.this, ReminderAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(ReminderCheckService.this, OpacClient.BROADCAST_REMINDER, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Log.i("ReminderCheckService", "Opac App Service: Quick repeat"); // Run again in 1 day am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (1000 * 3600 * 24), sender); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(OpacClient.NOTIF_ID); } else {//from w ww . j av a 2s .c om SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(ReminderCheckService.this); notification_on = sp.getBoolean("notification_service", false); long waittime = (1000 * 3600 * 5); boolean executed = false; 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) { executed = true; new CheckTask().execute(); } else { waittime = (1000 * 1800); } } else { waittime = (1000 * 1800); } if (!notification_on) { waittime = (1000 * 3600 * 12); } Intent i = new Intent(ReminderCheckService.this, ReminderAlarmReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(ReminderCheckService.this, OpacClient.BROADCAST_REMINDER, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + waittime, sender); if (!executed) { stopSelf(); } } return START_NOT_STICKY; }
From source file:com.phonemetra.account.util.AccountUtils.java
public static void scheduleRetry(Context context, SharedPreferences prefs, Intent intent) { int backoffTimeMs = getBackoff(prefs); int nextAttempt = backoffTimeMs / 2 + sRandom.nextInt(backoffTimeMs); if (Account.DEBUG) Log.d(TAG, "Scheduling retry, backoff = " + nextAttempt + " (" + backoffTimeMs + ") for " + intent.getAction());/*from www. ja va2s .co m*/ PendingIntent retryPendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + nextAttempt, retryPendingIntent); if (backoffTimeMs < Account.MAX_BACKOFF_MS) { setBackoff(prefs, backoffTimeMs * 2); } }
From source file:com.radioactiveyak.location_best_practices.services.PlaceCheckinService.java
@Override public void onCreate() { super.onCreate(); contentResolver = getContentResolver(); cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); sharedPreferences = getSharedPreferences(PlacesConstants.SHARED_PREFERENCE_FILE, Context.MODE_PRIVATE); sharedPreferencesEditor = sharedPreferences.edit(); sharedPreferenceSaver = PlatformSpecificImplementationFactory.getSharedPreferenceSaver(this); Intent retryIntent = new Intent(PlacesConstants.RETRY_QUEUED_CHECKINS_ACTION); retryQueuedCheckinsPendingIntent = PendingIntent.getBroadcast(this, 0, retryIntent, PendingIntent.FLAG_UPDATE_CURRENT); }
From source file:com.money.manager.ex.sync.SyncSchedulerBroadcastReceiver.java
private AlarmManager getAlarmManager(Context context) { return (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); }
From source file:com.capstone.transit.trans_it.RouteMap.java
@Override protected void onResume() { super.onResume(); setUpMapIfNeeded();//from ww w . j a v a 2 s .c o m positionsServiceIntent = new Intent(getApplicationContext(), RefreshPositionsService.class); positionsServiceIntent.putExtra("EXTRA_ROUTE_ID", routeID); positionsServiceIntent.putExtra("EXTRA_RECEIVER", new PositionsReceiver(new Handler())); final PendingIntent pendingIntent = PendingIntent.getService(this, 0, positionsServiceIntent, PendingIntent.FLAG_UPDATE_CURRENT); long trigger = System.currentTimeMillis(); int intervalMillis = 1000 * 60; AlarmManager alarm = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE); alarm.setRepeating(AlarmManager.RTC, trigger, intervalMillis, pendingIntent); }
From source file:ca.spencerelliott.mercury.ChangesetService.java
@Override public void onStart(Intent intent, int startId) { int broadcast_call = intent.getIntExtra("ca.spencerelliott.mercury.call", -1); //If this was on boot we want to set up the alarm to set up repeating notifications if (broadcast_call == AlarmReceiver.ON_BOOT) { //Get the alarm service AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); //Generate the interval between notifications, default to fifteen minutes long interval = Long.parseLong(prefs.getString("notification_interval", "900000")); //Create the intents to launch the service again Intent new_intent = new Intent("ca.spencerelliott.mercury.REFRESH_CHANGESETS"); PendingIntent p_intent = PendingIntent.getBroadcast(this, 0, new_intent, 0); final Calendar c = Calendar.getInstance(); //Create a repeating alarm alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, c.getTimeInMillis() + interval, interval, p_intent);// w ww.j a v a 2s .com //Stop the service since we're waiting for the interval stopSelf(); } //Create a new feed processor FeedProcessor processor = new FeedProcessor(); //Gather all of the URLs from the databases here //Let the processor handle all of the URLs and notify the user of any new changesets processor.execute(); }
From source file:com.cpd.receivers.LibraryRenewAlarmBroadcastReceiver.java
public void setAlarm(Context context) { Log.d(TAG, "setAlarm() called with: " + "context = [" + context + "]"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 12); calendar.set(Calendar.MINUTE, 1); calendar.set(Calendar.SECOND, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, LibraryRenewAlarmBroadcastReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(context, 1, intent, 0); am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY / DAILY_RETRIES, pi); }
From source file:nl.atcomputing.spacetravelagency.order.DepartureInfoService.java
static public void cancelDepartureInfoServiceAlarm(Context context) { Intent intent = new Intent(context, DepartureInfoService.class); PendingIntent pi = PendingIntent.getService(context, 1, intent, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi);/*w w w .j a v a 2 s . c om*/ }
From source file:com.devnoobs.bmr.Powiadomienia.java
public void cancelAlarm() { Intent i = new Intent(S); PendingIntent sender = PendingIntent.getBroadcast(c, 0, i, 0); AlarmManager alarmManager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(sender);//from w ww. ja v a 2s .c o m showToast("Powiadomienie wylaczone"); }