Last active
April 14, 2016 07:21
-
-
Save yishai-glide/1a22d773bb7145827cd4ca42b5713a1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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