android.content.ContentResolver#removePeriodicSync ( )源码实例Demo

下面列出了android.content.ContentResolver#removePeriodicSync ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cathode   文件: Accounts.java
public static void removeAccount(Context context) {
  try {
    AccountManager am = AccountManager.get(context);
    Account account = getAccount(context);
    ContentResolver.removePeriodicSync(account, BuildConfig.PROVIDER_AUTHORITY, new Bundle());
    ContentResolver.removePeriodicSync(account, BuildConfig.AUTHORITY_DUMMY_CALENDAR,
        new Bundle());
    AccountAuthenticator.allowRemove();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
      am.removeAccount(account, null, null, null);
    } else {
      am.removeAccount(account, null, null);
    }
  } catch (SecurityException e) {
    Timber.e(e, "Unable to remove account");
  }
}
 
源代码2 项目: aptoide-client   文件: MyAccountActivity.java
private void removeAccount(final Account account) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
    sharedPreferences.edit().remove("queueName").apply();
    ContentResolver.setIsSyncable(account, WEBINSTALL_SYNC_AUTHORITY, 0);
    ContentResolver.setSyncAutomatically(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, false);
    if(Build.VERSION.SDK_INT>=8){
        ContentResolver.removePeriodicSync(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, new Bundle());
    }
    mAccountManager.removeAccount(account, new AccountManagerCallback<Boolean>() {
        @Override
        public void run(AccountManagerFuture<Boolean> future) {
            addAccount();
            finish();
        }
    }, null);
}
 
源代码3 项目: moVirt   文件: AccountManagerHelper.java
/**
 * @param name     name of the account
 * @param password password of the account
 * @return created account or null if creation failed
 */
public MovirtAccount addAccount(String id, String name, String password) {
    Account newAccount = new Account(name, Constants.ACCOUNT_TYPE);
    boolean success = accountManager.addAccountExplicitly(newAccount, password, Bundle.EMPTY);

    MovirtAccount resultAccount = null;
    if (success) {
        accountManager.setUserData(newAccount, AccountProperty.ID.getPackageKey(), id);
        resultAccount = new MovirtAccount(id, newAccount);
        setAccountSyncable(resultAccount, false);
        ContentResolver.setSyncAutomatically(newAccount, OVirtContract.CONTENT_AUTHORITY, false);
        ContentResolver.removePeriodicSync(newAccount, OVirtContract.CONTENT_AUTHORITY, Bundle.EMPTY);
    }

    return resultAccount;
}
 
源代码4 项目: moVirt   文件: AccountManagerHelper.java
public void updatePeriodicSync(MovirtAccount account, boolean syncEnabled) {
    ObjectUtils.requireNotNull(account, "account");
    String authority = OVirtContract.CONTENT_AUTHORITY;
    Bundle bundle = Bundle.EMPTY;

    try {
        ContentResolver.setSyncAutomatically(account.getAccount(), OVirtContract.CONTENT_AUTHORITY, syncEnabled);

        if (syncEnabled) {
            long intervalInSeconds = environmentStore.getSharedPreferencesHelper(account).getPeriodicSyncInterval() * (long) Constants.SECONDS_IN_MINUTE;
            ContentResolver.addPeriodicSync(account.getAccount(), authority, bundle, intervalInSeconds);
        } else {
            ContentResolver.removePeriodicSync(account.getAccount(), authority, bundle);
        }
    } catch (AccountDeletedException ignored) {
    }
}
 
源代码5 项目: Capstone-Project   文件: PredatorSyncAdapter.java
public static void removePeriodicSync(Context context) {
    // Disable Sync
    ContentResolver.setIsSyncable(PredatorAccount.getAccount(context),
            Constants.Authenticator.PREDATOR_ACCOUNT_TYPE,
            Constants.Sync.OFF);

    Logger.d(TAG, "removePeriodicSync: true");
    ContentResolver.removePeriodicSync(
            PredatorAccount.getAccount(context),
            Constants.Authenticator.PREDATOR_ACCOUNT_TYPE,
            Bundle.EMPTY);
}
 
源代码6 项目: narrate-android   文件: SyncCard.java
private void enableSync() {
    Account acc = User.getAccount();


    ContentResolver.setIsSyncable(acc, Contract.AUTHORITY, 1);
    ContentResolver.setSyncAutomatically(acc, Contract.AUTHORITY, true);
    ContentResolver.removePeriodicSync(acc, Contract.AUTHORITY, Bundle.EMPTY);

    long interval = Settings.getAutoSyncInterval();

    if (interval > 0) {
        ContentResolver.addPeriodicSync(acc, Contract.AUTHORITY, Bundle.EMPTY, interval);
    }

    Bundle b = new Bundle();
    b.putBoolean("resync_files", true);

    SyncHelper.requestManualSync(acc, b);

    Toast.makeText(GlobalApplication.getAppContext(), GlobalApplication.getAppContext().getString(R.string.data_resyncing), Toast.LENGTH_SHORT).show();
}
 
@Override
public void removePeriodicSync(Account account, String authority, Bundle extras) {
    ContentResolver.removePeriodicSync(account, authority, extras);
}
 
源代码8 项目: haxsync   文件: QuickSettings.java
@Override
protected Void doInBackground(Void... params) {
	SharedPreferences prefs = context.getSharedPreferences(context.getPackageName() + "_preferences", Context.MODE_MULTI_PROCESS);
	SharedPreferences.Editor editor = prefs.edit();
   	
   	editor.putBoolean("sync_events", eventSync);
   	
   	editor.putBoolean("sync_birthdays", birthdaySync);
   	editor.putBoolean("sync_contact_birthday", birthdaySync);

   	editor.putBoolean("birthday_reminders", reminders);
   	editor.putBoolean("event_reminders", reminders);
   	
   	if (contactChoice == 1){
   		editor.putBoolean("phone_only", true);
   	} else if (contactChoice == 2){
   		editor.putBoolean("phone_only", false);
   	}
   	
   	editor.commit();
   	
	Account account = DeviceUtil.getAccount(context);
	
	long seconds = prefs.getLong("sync_seconds", 86400);

   	if (birthdaySync || eventSync){
   		ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, true);
   		ContentResolver.addPeriodicSync(account, CalendarContract.AUTHORITY, new Bundle(), seconds);
   	}else{
   		ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, false);
   		ContentResolver.removePeriodicSync(account, CalendarContract.AUTHORITY, new Bundle());
   	}
   	
   	if (contactChoice > 0){
   		ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true);
   		ContentResolver.addPeriodicSync(account, ContactsContract.AUTHORITY, new Bundle(), seconds);
   	}else{
   		ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, false);
   		ContentResolver.removePeriodicSync(account, ContactsContract.AUTHORITY, new Bundle());
   	}
   	return null;
}
 
源代码9 项目: cathode   文件: Upgrader.java
public static void upgrade(Context context) {
  final int currentVersion = Settings.get(context).getInt(SETTINGS_VERSION, -1);
  if (currentVersion == -1) {
    Settings.get(context)
        .edit()
        .putInt(SETTINGS_VERSION, VERSION)
        .putInt(Settings.VERSION_CODE, BuildConfig.VERSION_CODE)
        .apply();
    return;
  }

  if (currentVersion < VERSION) {
    if (currentVersion < 1) {
      if (TraktLinkSettings.isLinked(context)) {
        Account account = Accounts.getAccount(context);
        ContentResolver.removePeriodicSync(account, BuildConfig.PROVIDER_AUTHORITY,
            new Bundle());
        ContentResolver.setSyncAutomatically(account, BuildConfig.PROVIDER_AUTHORITY, false);
        ContentResolver.setIsSyncable(account, BuildConfig.PROVIDER_AUTHORITY, 0);
      }
    }

    if (currentVersion < 2) {
      Settings.get(context)
          .edit()
          .remove("suggestions")
          .remove("lastSyncHidden")
          .remove("lastPurge")
          .remove("tmdbLastConfigurationUpdate")
          .apply();
    }

    if (currentVersion < 3) {
      TraktTimestamps.getSettings(context).edit().remove(TraktTimestamps.EPISODE_RATING).apply();
    }

    if (currentVersion < 4) {
      boolean linked = Settings.get(context).getBoolean(TraktLinkSettings.TRAKT_LINKED, false);
      if (linked) {
        Settings.get(context)
            .edit()
            .putBoolean(TraktLinkSettings.TRAKT_LINK_PROMPTED, true)
            .apply();
      }
    }

    if (currentVersion < 6) {
      TraktTimestamps.clear(context);
    }

    Settings.get(context).edit().putInt(SETTINGS_VERSION, VERSION).apply();
  }

  Settings.get(context).edit().putInt(Settings.VERSION_CODE, BuildConfig.VERSION_CODE).apply();
}