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

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

源代码1 项目: mobly-bundled-snippets   文件: AccountSnippet.java
/**
 * Updates ContentResolver sync settings for an Account's specified SyncAdapter.
 *
 * <p>Sets an accounts SyncAdapter (selected based on authority) to sync/not-sync automatically
 * and immediately requests/cancels a sync.
 *
 * <p>updateSync should always be called under {@link AccountSnippet#mLock} write lock to avoid
 * flapping between the getSyncAutomatically and setSyncAutomatically calls.
 *
 * @param account A Google Account.
 * @param authority The authority of a content provider that should (not) be synced.
 * @param sync Whether or not the account's content provider should be synced.
 */
private void updateSync(Account account, String authority, boolean sync) {
    if (ContentResolver.getSyncAutomatically(account, authority) != sync) {
        ContentResolver.setSyncAutomatically(account, authority, sync);
        if (sync) {
            ContentResolver.requestSync(account, authority, new Bundle());
        } else {
            ContentResolver.cancelSync(account, authority);
        }
        Log.i(
                "Set sync to "
                        + sync
                        + " for account "
                        + account
                        + ", adapter "
                        + authority
                        + ".");
    }
}
 
源代码2 项目: narrate-android   文件: SyncHelper.java
public static void requestManualSync(Account mChosenAccount, Bundle extras) {
    if (mChosenAccount != null &&
            ContentResolver.getSyncAutomatically(User.getAccount(), Contract.AUTHORITY)) {

        LogUtil.log(TAG, "Requesting manual sync for account " + mChosenAccount.name);

        Bundle b = new Bundle(extras);
        b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);

        cancelPendingActiveSync(mChosenAccount);

        LogUtil.log(TAG, "Requesting sync now.");
        ContentResolver.requestSync(mChosenAccount, Contract.AUTHORITY, b);
    } else {
        LogUtil.log(TAG, "Can't request manual sync -- no chosen account.");
    }
}
 
源代码3 项目: haxsync   文件: WizardActivity.java
private void readSettings(){
  	Account account = DeviceUtil.getAccount(this);
  	boolean contactSync = true;
  	boolean calendarSync = true;
  	if (account != null){
   	contactSync = ContentResolver.getSyncAutomatically(account, ContactsContract.AUTHORITY);
   	calendarSync = ContentResolver.getSyncAutomatically(account, CalendarContract.AUTHORITY);
  	}
SharedPreferences prefs = getSharedPreferences(getPackageName() + "_preferences", MODE_MULTI_PROCESS);

  	if (!contactSync)
  		contactSpinner.setSelection(0);
  	else if (prefs.getBoolean("phone_only", true))
  		contactSpinner.setSelection(1);
  	else
  		contactSpinner.setSelection(2);
  	
eventSwitch.setChecked(prefs.getBoolean("sync_events", true) && calendarSync);
birthdaySwitch.setChecked(prefs.getBoolean("sync_birthdays", true) && calendarSync);
reminderSwitch.setChecked(prefs.getBoolean("event_reminders", true));
wizardCheck.setChecked(!DeviceUtil.isWizardShown(this));
toggleReminderVisibility();
  }
 
源代码4 项目: mollyim-android   文件: DirectoryHelperV1.java
private static Optional<AccountHolder> getOrCreateAccount(Context context) {
  AccountManager accountManager = AccountManager.get(context);
  Account[]      accounts       = accountManager.getAccountsByType(context.getPackageName());

  Optional<AccountHolder> account;

  if (accounts.length == 0) account = createAccount(context);
  else                      account = Optional.of(new AccountHolder(accounts[0], false));

  if (account.isPresent() && !ContentResolver.getSyncAutomatically(account.get().getAccount(), ContactsContract.AUTHORITY)) {
    ContentResolver.setSyncAutomatically(account.get().getAccount(), ContactsContract.AUTHORITY, true);
  }

  return account;
}
 
@Override
public boolean getSyncAutomatically(Account account, String authority) {
    return ContentResolver.getSyncAutomatically(account, authority);
}
 
源代码6 项目: android_maplibui   文件: NGWSettingsFragment.java
public static boolean isAccountSyncEnabled(
        Account account,
        String authority)
{
    return null != account && ContentResolver.getSyncAutomatically(account, authority);
}
 
源代码7 项目: COCOFramework   文件: SyncAdapterHelper.java
public boolean isAutoSync(Account mAccount) {
    return ContentResolver.getIsSyncable(mAccount, AUTHORITY) > 0 && ContentResolver.getMasterSyncAutomatically() && ContentResolver.getSyncAutomatically(mAccount, AUTHORITY);
}
 
源代码8 项目: moVirt   文件: AccountManagerHelper.java
public boolean isPeriodicSyncable(MovirtAccount account) throws AccountDeletedException {
    return account != null && ContentResolver.getSyncAutomatically(account.getAccount(), OVirtContract.CONTENT_AUTHORITY);
}
 
@Override
public boolean getSyncAutomatically(Account account, String authority) {
    return ContentResolver.getSyncAutomatically(account, authority);
}
 
@Override
public boolean getSyncAutomatically(Account account, String authority) {
    return ContentResolver.getSyncAutomatically(account, authority);
}