當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentResolver.getSyncAutomatically方法代碼示例

本文整理匯總了Java中android.content.ContentResolver.getSyncAutomatically方法的典型用法代碼示例。如果您正苦於以下問題:Java ContentResolver.getSyncAutomatically方法的具體用法?Java ContentResolver.getSyncAutomatically怎麽用?Java ContentResolver.getSyncAutomatically使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.ContentResolver的用法示例。


在下文中一共展示了ContentResolver.getSyncAutomatically方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateSync

import android.content.ContentResolver; //導入方法依賴的package包/類
/**
 * 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
                        + ".");
    }
}
 
開發者ID:google,項目名稱:mobly-bundled-snippets,代碼行數:32,代碼來源:AccountSnippet.java

示例2: setSyncActivated

import android.content.ContentResolver; //導入方法依賴的package包/類
public void setSyncActivated(boolean enabled) {
	
       ContentResolver.setMasterSyncAutomatically(enabled);
       
       if (enabled) {
       	SyncAdapterType[] types = ContentResolver.getSyncAdapterTypes();
       	AccountManager accmgr = AccountManager.get(mContext);
       	for (SyncAdapterType type : types) {
       		
       		Account[] accounts = accmgr.getAccountsByType(type.accountType);
       		for (Account account : accounts) {
       			
       			if (Constants.DEBUG) {
       				Log.d(TAG, "synching account, name:" + account.name  + ", type: " + account.type);
       			}
       			
       			enabled = ContentResolver.getSyncAutomatically(account, type.authority);
       			if (enabled) {
       				// trigger update for next account
       				ContentResolver.requestSync(account, type.authority, new Bundle());
       			}
       		}
       	}
       }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:26,代碼來源:SyncControl20.java

示例3: getOrCreateAccount

import android.content.ContentResolver; //導入方法依賴的package包/類
private static Optional<AccountHolder> getOrCreateAccount(Context context) {
  AccountManager accountManager = AccountManager.get(context);
  Account[]      accounts       = accountManager.getAccountsByType("im.cable.cableim");

  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;
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:16,代碼來源:DirectoryHelper.java

示例4: getOrCreateAccount

import android.content.ContentResolver; //導入方法依賴的package包/類
private static Optional<AccountHolder> getOrCreateAccount(Context context) {
  AccountManager accountManager = AccountManager.get(context);
  Account[]      accounts       = accountManager.getAccountsByType("id.kita.pesan.secure");

  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;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:16,代碼來源:DirectoryHelper.java


注:本文中的android.content.ContentResolver.getSyncAutomatically方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。