Search in sources :

Example 1 with AlarmManager

use of android.app.AlarmManager in project cw-omnibus by commonsguy.

the class PollReceiver method scheduleAlarms.

static void scheduleAlarms(Context ctxt) {
    AlarmManager mgr = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
    Thingy thingy = new Thingy(mgr.getClass().getCanonicalName(), mgr.hashCode());
    Intent i = new Intent(ctxt, PollReceiver.class).putExtra(EXTRA_THINGY, Parcelables.toByteArray(thingy));
    PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INITIAL_DELAY, PERIOD, pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 2 with AlarmManager

use of android.app.AlarmManager in project cw-omnibus by commonsguy.

the class MainActivity method notifyMe.

public void notifyMe(View v) {
    Intent i = new Intent(this, AlarmReceiver.class).putExtra(AlarmReceiver.EXTRA_TYPE, type.getSelectedItemPosition());
    PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
    AlarmManager mgr = (AlarmManager) getSystemService(ALARM_SERVICE);
    mgr.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + (1000 * delay.getProgress()), pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 3 with AlarmManager

use of android.app.AlarmManager in project cw-omnibus by commonsguy.

the class PollReceiver method scheduleAlarms.

static void scheduleAlarms(Context ctxt) {
    AlarmManager mgr = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(ctxt, PollReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);
    Intent i2 = new Intent(ctxt, EventDemoActivity.class);
    PendingIntent pi2 = PendingIntent.getActivity(ctxt, 0, i2, 0);
    AlarmManager.AlarmClockInfo ac = new AlarmManager.AlarmClockInfo(System.currentTimeMillis() + PERIOD, pi2);
    mgr.setAlarmClock(ac, pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 4 with AlarmManager

use of android.app.AlarmManager in project cw-omnibus by commonsguy.

the class PollReceiver method scheduleAlarms.

static void scheduleAlarms(Context ctxt) {
    AlarmManager mgr = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(ctxt, PollReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INITIAL_DELAY, PERIOD, pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 5 with AlarmManager

use of android.app.AlarmManager in project cw-omnibus by commonsguy.

the class PollReceiver method scheduleAlarms.

static void scheduleAlarms(Context ctxt) {
    AlarmManager mgr = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE);
    Intent i = new Intent(ctxt, PollReceiver.class);
    PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + INITIAL_DELAY, PERIOD, pi);
}
Also used : AlarmManager(android.app.AlarmManager) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Aggregations

AlarmManager (android.app.AlarmManager)471 PendingIntent (android.app.PendingIntent)349 Intent (android.content.Intent)323 Calendar (java.util.Calendar)75 SuppressLint (android.annotation.SuppressLint)24 Date (java.util.Date)24 Context (android.content.Context)22 SharedPreferences (android.content.SharedPreferences)20 SimpleDateFormat (java.text.SimpleDateFormat)18 Test (org.junit.Test)17 VisibleForTesting (com.android.internal.annotations.VisibleForTesting)13 Config (org.robolectric.annotation.Config)13 Handler (android.os.Handler)11 HashMap (java.util.HashMap)11 PowerManager (android.os.PowerManager)10 File (java.io.File)10 Map (java.util.Map)10 Activity (android.app.Activity)9 ShadowAlarmManager (org.robolectric.shadows.ShadowAlarmManager)9 TargetApi (android.annotation.TargetApi)8