Example #1
0
 public void Sync(Context con)
 {
     try
     {
         var     am      = AccountManager.Get(con.ApplicationContext);
         Account account = am.GetAccountsByType(ACCOUNT_TYPE)[0];
         var     isYourAccountSyncEnabled = ContentResolver.GetSyncAutomatically(account, AUTHORITY);
         var     isMasterSyncEnabled      = ContentResolver.MasterSyncAutomatically;
         if (!isYourAccountSyncEnabled && isMasterSyncEnabled)
         {
             instance = new CustomContentResolver(con.ApplicationContext);
         }
     }
     catch (Exception)
     {
         mAccount = null;
         instance = new CustomContentResolver(con.ApplicationContext);
     }
     finally
     {
         ContentResolver.SetIsSyncable(mAccount, AUTHORITY, 1);
         var data = new Bundle();
         data.PutBoolean(ContentResolver.SyncExtrasManual, true);
         data.PutBoolean(ContentResolver.SyncExtrasExpedited, true);
         ContentResolver.RequestSync(mAccount, AUTHORITY, data);
     }
 }