Created
May 21, 2012 13:22
-
-
Save Axxiss/2762286 to your computer and use it in GitHub Desktop.
Sync adapter
This file contains 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 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