Skip to content

Retry if GCM registration fails - #20

Merged
DanielNovak merged 1 commit into
masterfrom
error_retry
Feb 25, 2015
Merged

Retry if GCM registration fails#20
DanielNovak merged 1 commit into
masterfrom
error_retry

Conversation

@DanielNovak

Copy link
Copy Markdown

@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 on AsyncTask.THREAD_POOL_EXECUTOR to 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_CHANGED broadcast. (WakeLock is not held during normal registration started from MainActivity).

Thanks for taking a look.

@davidvavra

Copy link
Copy Markdown
Contributor

LGTM (Looks good to me :)

DanielNovak pushed a commit that referenced this pull request Feb 25, 2015
Retry if GCM registration fails
@DanielNovak
DanielNovak merged commit ed98150 into master Feb 25, 2015
@DanielNovak
DanielNovak deleted the error_retry branch June 30, 2015 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants