Example usage for android.app AlarmManager ELAPSED_REALTIME_WAKEUP

List of usage examples for android.app AlarmManager ELAPSED_REALTIME_WAKEUP

Introduction

In this page you can find the example usage for android.app AlarmManager ELAPSED_REALTIME_WAKEUP.

Prototype

int ELAPSED_REALTIME_WAKEUP

To view the source code for android.app AlarmManager ELAPSED_REALTIME_WAKEUP.

Click Source Link

Document

Alarm time in android.os.SystemClock#elapsedRealtime SystemClock.elapsedRealtime() (time since boot, including sleep), which will wake up the device when it goes off.

Usage

From source file:com.geotrackin.gpslogger.GpsLoggingService.java

private void SetAlarmForNextPoint() {

    tracer.debug("GpsLoggingService.SetAlarmForNextPoint");

    Intent i = new Intent(this, GpsLoggingService.class);

    i.putExtra("getnextpoint", true);

    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);/*from   w  w  w .jav  a  2  s .  co m*/

    nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + AppSettings.getMinimumSeconds() * 1000, pi);

}

From source file:org.ohmage.reminders.types.location.LocTrigService.java

private void setSamplingAlarm(String action, long timeOut, int extra) {
    Log.v(TAG, "LocTrigService: Setting alarm: " + action);

    cancelSamplingAlarm(action);/* w  ww .j  a  v a 2  s . co  m*/

    Intent i = new Intent(action);
    i.setPackage(getPackageName());
    i.putExtra(KEY_SAMPLING_ALARM_EXTRA, extra);
    PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);

    AlarmManager alarmMan = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmMan.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + timeOut, pi);
}

From source file:com.andrew.apollo.MusicPlaybackService.java

private void scheduleDelayedShutdown() {
    if (mAlarmManager != null && mShutdownIntent != null) {

        if (mShutdownScheduled) {
            cancelShutdown();/*from w w w  .j  a  v a 2 s.  c  om*/
        }

        if (isPlaying()) {
            LOG.info("scheduleDelayedShutdown() aborted, audio is playing.");
            mShutdownScheduled = true;
            return;
        }

        if (D)
            LOG.info("Scheduling shutdown in " + IDLE_DELAY + " ms");
        mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + IDLE_DELAY,
                mShutdownIntent);
        mShutdownScheduled = true;
    } else {
        mShutdownScheduled = false;
    }
}

From source file:org.ohmage.triggers.types.location.LocTrigService.java

private void setSamplingAlarm(String action, long timeOut, int extra) {
    Log.i(DEBUG_TAG, "LocTrigService: Setting alarm: " + action);

    cancelSamplingAlarm(action);/*from   w  ww  . ja v a  2s .  c  o m*/

    Intent i = new Intent(action);
    i.putExtra(KEY_SAMPLING_ALARM_EXTRA, extra);
    PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);

    AlarmManager alarmMan = (AlarmManager) getSystemService(ALARM_SERVICE);
    alarmMan.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + timeOut, pi);
}

From source file:com.b44t.messenger.NotificationsController.java

private void scheduleNotificationRepeat() {
    try {//w w w.ja va2 s .  c  o  m
        PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0,
                new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0);
        SharedPreferences preferences = ApplicationLoader.applicationContext
                .getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
        int minutes = preferences.getInt("repeat_messages", 0);
        if (minutes > 0 && personal_count > 0) {
            alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                    SystemClock.elapsedRealtime() + minutes * 60 * 1000, pintent);
        } else {
            alarmManager.cancel(pintent);
        }
    } catch (Exception e) {
        FileLog.e("messenger", e);
    }
}

From source file:org.ozonecity.gpslogger2.GpsLoggingService.java

private void SetAlarmForNextPoint() {
    tracer.debug("Set alarm for " + AppSettings.getMinimumSeconds() + " seconds");

    Intent i = new Intent(this, GpsLoggingService.class);
    i.putExtra(IntentConstants.GET_NEXT_POINT, true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);/*from   w  ww.j  ava 2 s  . c o m*/

    nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + AppSettings.getMinimumSeconds() * 1000, pi);
}

From source file:com.crearo.gpslogger.GpsLoggingService.java

@TargetApi(23)
private void setAlarmForNextPoint() {
    LOG.debug("Set alarm for " + preferenceHelper.getMinimumLoggingInterval() + " seconds");

    Intent i = new Intent(this, GpsLoggingService.class);
    i.putExtra(IntentConstants.GET_NEXT_POINT, true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);// www .  ja  v a  2  s. c  om

    if (Systems.isDozing(this)) {
        //Only invoked once per 15 minutes in doze mode
        LOG.debug("Device is dozing, using infrequent alarm");
        nextPointAlarmManager.setAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + preferenceHelper.getMinimumLoggingInterval() * 1000, pi);
    } else {
        nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + preferenceHelper.getMinimumLoggingInterval() * 1000, pi);
    }
}

From source file:com.mendhak.gpslogger.GpsLoggingService.java

@TargetApi(23)
private void setAlarmForNextPoint() {
    LOG.debug("Set alarm for " + preferenceHelper.getMinimumLoggingInterval() + " seconds");

    Intent i = new Intent(this, GpsLoggingService.class);
    i.putExtra(IntentConstants.GET_NEXT_POINT, true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);//from   w  w  w. jav  a 2  s. c  o  m

    if (Systems.isDozing(this)) {
        //Only invoked once per 15 minutes in doze mode
        LOG.warn("Device is dozing, using infrequent alarm");
        nextPointAlarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + preferenceHelper.getMinimumLoggingInterval() * 1000, pi);
    } else {
        nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + preferenceHelper.getMinimumLoggingInterval() * 1000, pi);
    }
}

From source file:com.raddapp.radika.raddappv001.GpsLoggingService.java

private void SetAlarmForNextPoint() {
    Log.d("GPSLOGSERV 101", "SetAlarmForNextPoint");

    //tracer.debug("Set alarm for " + 3 + " seconds");//AppSettings.getMinimumLoggingInterval()

    Intent i = new Intent(this, GpsLoggingService.class);
    i.putExtra(IntentConstants.GET_NEXT_POINT, true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);//from   w  ww  . j av  a2 s. co m

    nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1 * 1000,
            pi); //AppSettings.getMinimumLoggingInterval()
}

From source file:com.mjhram.geodata.GpsLoggingService.java

private void SetAlarmForNextPoint() {
    tracer.debug("Set alarm for " + AppSettings.getMinimumLoggingInterval() + " seconds");

    Intent i = new Intent(this, GpsLoggingService.class);
    i.putExtra(IntentConstants.GET_NEXT_POINT, true);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    nextPointAlarmManager.cancel(pi);/* w ww .j a  va 2s .  co m*/

    nextPointAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
            SystemClock.elapsedRealtime() + AppSettings.getMinimumLoggingInterval() * 1000, pi);
}