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


Java ContentResolver.setMasterSyncAutomatically方法代碼示例

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


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

示例1: 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

示例2: onHandleIntent

import android.content.ContentResolver; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getAction().equals(ACTION_TOGGLE_SYNC)) {
        final boolean newState;
        if (intent.hasExtra(AShortcut.EXTRA_ENABLE)) {
            newState = intent.getBooleanExtra(AShortcut.EXTRA_ENABLE, false);
        } else {
            newState = !ContentResolver.getMasterSyncAutomatically();
        }
        ContentResolver.setMasterSyncAutomatically(newState);
        if (intent.getBooleanExtra(AShortcut.EXTRA_SHOW_TOAST, false)) {
            showToast(newState ? 
                    R.string.quick_settings_sync_on :
                        R.string.quick_settings_sync_off);
        }
    } else if (intent.getAction().equals(ACTION_GET_SYNC_STATUS)) {
        boolean syncStatus = ContentResolver.getMasterSyncAutomatically();
        ResultReceiver receiver = intent.getParcelableExtra("receiver");
        Bundle data = new Bundle();
        data.putBoolean(KEY_SYNC_STATUS, syncStatus);
        receiver.send(RESULT_SYNC_STATUS, data);
    } else if (intent.getAction().equals(QuietHoursActivity.ACTION_SET_QUIET_HOURS_MODE)) {
        QuietHours.Mode qhMode = QuietHoursActivity.setQuietHoursMode(this, intent.getStringExtra(
                QuietHoursActivity.EXTRA_QH_MODE));
        if (qhMode != null && intent.getBooleanExtra(AShortcut.EXTRA_SHOW_TOAST, false)) {
            showToast(QuietHoursActivity.getToastResIdFromMode(qhMode));
        }
    }
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:30,代碼來源:GravityBoxService.java


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