Skip to content

Instantly share code, notes, and snippets.

@Axxiss
Created May 21, 2012 13:22
Show Gist options
  • Save Axxiss/2762286 to your computer and use it in GitHub Desktop.
Save Axxiss/2762286 to your computer and use it in GitHub Desktop.
Sync adapter
public class SyncAdapter extends AbstractThreadedSyncAdapter {
private final static String TAG = "SyncAdapter";
private AccountManager mAccountManager;
public SyncAdapter(Context context, boolean autoInitialize) {
super(context, autoInitialize);
mAccountManager = AccountManager.get(context);
}
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
String authToken = null;
try {
authToken = mAccountManager.blockingGetAuthToken(account,
Authenticator.AUTHTOKEN_TYPE, true);
} catch (OperationCanceledException e) {
Log.e(TAG, "Operation cancelled");
e.printStackTrace();
} catch (AuthenticatorException e) {
Log.e(TAG, "Authenticator exception");
e.printStackTrace();
} catch (IOException e) {
Log.e(TAG, "I/O error");
e.printStackTrace();
}
//synchronization
VideoLogger.syncLog(getContext(), account.name, authToken);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment