com.google.ipc.invalidation.external.client.contrib.AndroidListener.AlarmReceiver Java Examples
The following examples show how to use
com.google.ipc.invalidation.external.client.contrib.AndroidListener.AlarmReceiver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidListenerIntents.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** Issues a registration retry with delay. */ static void issueDelayedRegistrationIntent(Context context, AndroidClock clock, ByteString clientId, ObjectId objectId, boolean isRegister, int delayMs, int requestCode) { RegistrationCommand command = isRegister ? AndroidListenerProtos.newDelayedRegisterCommand(clientId, objectId) : AndroidListenerProtos.newDelayedUnregisterCommand(clientId, objectId); Intent intent = new Intent() .putExtra(EXTRA_REGISTRATION, command.toByteArray()) .setClass(context, AlarmReceiver.class); // Create a pending intent that will cause the AlarmManager to fire the above intent. PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_ONE_SHOT); // Schedule the pending intent after the appropriate delay. AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); long executeMs = clock.nowMs() + delayMs; alarmManager.set(AlarmManager.RTC, executeMs, pendingIntent); }
Example #2
Source File: AndroidListenerIntents.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** Issues a registration retry with delay. */ static void issueDelayedRegistrationIntent(Context context, AndroidClock clock, ByteString clientId, ObjectId objectId, boolean isRegister, int delayMs, int requestCode) { RegistrationCommand command = isRegister ? AndroidListenerProtos.newDelayedRegisterCommand(clientId, objectId) : AndroidListenerProtos.newDelayedUnregisterCommand(clientId, objectId); Intent intent = new Intent() .putExtra(EXTRA_REGISTRATION, command.toByteArray()) .setClass(context, AlarmReceiver.class); // Create a pending intent that will cause the AlarmManager to fire the above intent. PendingIntent pendingIntent = PendingIntent.getBroadcast(context, requestCode, intent, PendingIntent.FLAG_ONE_SHOT); // Schedule the pending intent after the appropriate delay. AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); long executeMs = clock.nowMs() + delayMs; alarmManager.set(AlarmManager.RTC, executeMs, pendingIntent); }
Example #3
Source File: AndroidListenerIntents.java From 365browser with Apache License 2.0 | 4 votes |
/** Constructs an intent indicating that scheduled tasks should run. */ static Intent createScheduledTaskintent(Context context) { return new Intent() .putExtra(EXTRA_SCHEDULED_TASK, true) .setClass(context, AlarmReceiver.class); }