Skip to content

Instantly share code, notes, and snippets.

Created September 24, 2019 14:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Aksi0m/2e60f7a8e5708d37be89362b682c6111 to your computer and use it in GitHub Desktop.
This is a sync adapter that runs in the background, so you can run the synchronous patching.
public class SyncAdapter extends AbstractThreadedSyncAdapter {
// This is called each time a sync is attempted; this is okay, since the
// overhead is negligible if the security provider is up-to-date.
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
try {
} catch (GooglePlayServicesRepairableException e) {
// Indicates that Google Play services is out of date, disabled, etc.
// Prompt the user to install/update/enable Google Play services.
e.getConnectionStatusCode(), getContext());
// Notify the SyncManager that a soft error occurred.
} catch (GooglePlayServicesNotAvailableException e) {
// Indicates a non-recoverable error; the ProviderInstaller is not able
// to install an up-to-date Provider.
// Notify the SyncManager that a hard error occurred.
//in this case: make sure that you inform your API of it.
// If this is reached, you know that the provider was already up-to-date,
// or was successfully updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment