当前位置: 首页>>代码示例>>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;未经允许,请勿转载。