Skip to content

Instantly share code, notes, and snippets.

@yishai-glide
Last active April 14, 2016 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yishai-glide/1a22d773bb7145827cd4ca42b5713a1a to your computer and use it in GitHub Desktop.
Save yishai-glide/1a22d773bb7145827cd4ca42b5713a1a to your computer and use it in GitHub Desktop.
public synchronized static void registerService(Context applicationContext) {
Intent serviceIntent = new Intent(applicationContext, GcmRegistrationService.class);
PendingIntent scheduleIntetnt = PendingIntent.getService(GlideApplication.applicationContext, REQUEST_CODE, serviceIntent, PendingIntent.FLAG_UPDATE_CURRENT);
if (scheduleIntetnt == null) {
if(DEBUG) {
Utils.log(TAG, "no need to schedule again since there is already a PendingIntent in the queue", 1);
}
return;
}
long now = System.currentTimeMillis();
long backoff = sharedPrefsManager.incrementGcmBackoff();
long when = now + backoff;
am.set(AlarmManager.RTC_WAKEUP, when, scheduleIntetnt);
Utils.log(TAG, "scheduled intent to run in " + when + " millis", 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment