List of usage examples for android.content ContentResolver removePeriodicSync
public static void removePeriodicSync(Account account, String authority, Bundle extras)
From source file:com.ntsync.android.sync.shared.SyncUtils.java
public static void removePeriodicSync(String authority, Bundle extras, Context context) { AccountManager am = AccountManager.get(context); Account[] accounts = am.getAccountsByType(Constants.ACCOUNT_TYPE); for (Account ac : accounts) { ContentResolver.removePeriodicSync(ac, authority, extras); }// www . j a va 2 s . c o m }
From source file:com.jefftharris.passwdsafe.sync.gdrive.GDriveProvider.java
@Override public void updateSyncFreq(Account acct, int freq) { if (acct != null) { ContentResolver.removePeriodicSync(acct, PasswdSafeContract.AUTHORITY, new Bundle()); ContentResolver.setSyncAutomatically(acct, PasswdSafeContract.AUTHORITY, false); if (freq > 0) { ContentResolver.setSyncAutomatically(acct, PasswdSafeContract.AUTHORITY, true); ContentResolver.addPeriodicSync(acct, PasswdSafeContract.AUTHORITY, new Bundle(), freq); }/* w ww . java 2s. com*/ } }
From source file:ie.clashoftheash.timetabler.ui.SettingsActivity.java
@Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.equals(prefKeyProgrammeCode) || key.equals(prefKeyYear)) { // Update account String programme = sharedPreferences.getString(prefKeyProgrammeCode, AccountUtils.getProgrammeCode(this)); String year = sharedPreferences.getString(prefKeyYear, AccountUtils.getYear(this)); new AccountUtils(this).updateAccount(programme, year); } else if (key.equals(prefKeyFreq)) { long pollFrequency = getSyncFreqPref(); Account acc = AccountUtils.getAccount(this); String authority = Timetable.AUTHORITY; if (pollFrequency > 0) { ContentResolver.setSyncAutomatically(acc, authority, true); ContentResolver.addPeriodicSync(acc, authority, new Bundle(), pollFrequency); } else {/*from ww w .j a va 2 s . co m*/ ContentResolver.setSyncAutomatically(acc, authority, false); ContentResolver.removePeriodicSync(acc, authority, new Bundle()); } } }
From source file:org.andstatus.app.account.AccountData.java
private void setSyncFrequencySeconds(Account androidAccount, long syncFrequencySeconds) { // See//w ww . j a v a 2 s .co m // http://developer.android.com/reference/android/content/ContentResolver.html#addPeriodicSync(android.accounts.Account, java.lang.String, android.os.Bundle, long) // and // http://stackoverflow.com/questions/11090604/android-syncadapter-automatically-initialize-syncing ContentResolver.removePeriodicSync(androidAccount, MyProvider.AUTHORITY, new Bundle()); if (syncFrequencySeconds > 0) { ContentResolver.addPeriodicSync(androidAccount, MyProvider.AUTHORITY, new Bundle(), syncFrequencySeconds); } }
From source file:com.ntsync.android.sync.shared.SyncUtils.java
/** * Create a new Account and activate the automatic sync * /*from w ww. j a v a2 s .com*/ * @param account * null is not allowed * @param accountManager * null is not allowed * @param password * null is not allowed */ public static boolean createAccount(Context context, final Account account, AccountManager accountManager, String password) { boolean added = accountManager.addAccountExplicitly(account, password, null); if (added) { List<PeriodicSync> syncs = ContentResolver.getPeriodicSyncs(account, ContactsContract.AUTHORITY); if (syncs != null) { // Remove default syncs. for (PeriodicSync periodicSync : syncs) { ContentResolver.removePeriodicSync(account, ContactsContract.AUTHORITY, periodicSync.extras); } } SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); int synctime; try { synctime = settings.getInt("pref_synctime", DEFAULT_SYNCINTERVAL); } catch (ClassCastException e) { LogHelper.logI(TAG, "Invalid SyncTime-Settingvalue", e); synctime = DEFAULT_SYNCINTERVAL; } if (synctime != 0) { addPeriodicSync(ContactsContract.AUTHORITY, Bundle.EMPTY, synctime, context); } // Set contacts sync for this account. ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true); } else { LogHelper.logI(TAG, "Account " + account.name + " is already available."); } return added; }