Retry if GCM registration fails - #20
Merged
Merged
Conversation
Contributor
|
LGTM (Looks good to me :) |
DanielNovak
force-pushed
the
error_retry
branch
from
February 24, 2015 22:33
b14df47 to
aed27df
Compare
DanielNovak
pushed a commit
that referenced
this pull request
Feb 25, 2015
Retry if GCM registration fails
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@destil @martinadamek I created a "naive" implementation for the exponential back-off in the branch error_retry. I am just retrying the registration inside the AsyncTask and delaying the next retry by
Thread.sleep(). The registration is retried after 2, 4, 8, 16 and 32 seconds. The AsyncTask is executed onAsyncTask.THREAD_POOL_EXECUTORto prevent blocking other AsyncTasks on Android 3.0+ (as they run in serial).This could have been done by a Service, AlarmManager or maybe Handler - but I think it does not matter if the system kills the AsyncTask or if it's not 100% guaranteed to retry exactly 5 times. So this seemed to me like a good compromise and a simple implementation (easier to understand/modify).
The wakelock will be release after 5 retries in a special case of the
MY_PACKAGE_CHANGEDbroadcast. (WakeLock is not held during normal registration started from MainActivity).Thanks for taking a look.