Java Code Examples for android.content.ContentResolver#removePeriodicSync()
The following examples show how to use
android.content.ContentResolver#removePeriodicSync() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Accounts.java From cathode with Apache License 2.0 | 7 votes |
public static void removeAccount(Context context) { try { AccountManager am = AccountManager.get(context); Account account = getAccount(context); ContentResolver.removePeriodicSync(account, BuildConfig.PROVIDER_AUTHORITY, new Bundle()); ContentResolver.removePeriodicSync(account, BuildConfig.AUTHORITY_DUMMY_CALENDAR, new Bundle()); AccountAuthenticator.allowRemove(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { am.removeAccount(account, null, null, null); } else { am.removeAccount(account, null, null); } } catch (SecurityException e) { Timber.e(e, "Unable to remove account"); } }
Example 2
Source File: MyAccountActivity.java From aptoide-client with GNU General Public License v2.0 | 6 votes |
private void removeAccount(final Account account) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); sharedPreferences.edit().remove("queueName").apply(); ContentResolver.setIsSyncable(account, WEBINSTALL_SYNC_AUTHORITY, 0); ContentResolver.setSyncAutomatically(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, false); if(Build.VERSION.SDK_INT>=8){ ContentResolver.removePeriodicSync(account, MyAccountActivity.WEBINSTALL_SYNC_AUTHORITY, new Bundle()); } mAccountManager.removeAccount(account, new AccountManagerCallback<Boolean>() { @Override public void run(AccountManagerFuture<Boolean> future) { addAccount(); finish(); } }, null); }
Example 3
Source File: AccountManagerHelper.java From moVirt with Apache License 2.0 | 6 votes |
/** * @param name name of the account * @param password password of the account * @return created account or null if creation failed */ public MovirtAccount addAccount(String id, String name, String password) { Account newAccount = new Account(name, Constants.ACCOUNT_TYPE); boolean success = accountManager.addAccountExplicitly(newAccount, password, Bundle.EMPTY); MovirtAccount resultAccount = null; if (success) { accountManager.setUserData(newAccount, AccountProperty.ID.getPackageKey(), id); resultAccount = new MovirtAccount(id, newAccount); setAccountSyncable(resultAccount, false); ContentResolver.setSyncAutomatically(newAccount, OVirtContract.CONTENT_AUTHORITY, false); ContentResolver.removePeriodicSync(newAccount, OVirtContract.CONTENT_AUTHORITY, Bundle.EMPTY); } return resultAccount; }
Example 4
Source File: AccountManagerHelper.java From moVirt with Apache License 2.0 | 6 votes |
public void updatePeriodicSync(MovirtAccount account, boolean syncEnabled) { ObjectUtils.requireNotNull(account, "account"); String authority = OVirtContract.CONTENT_AUTHORITY; Bundle bundle = Bundle.EMPTY; try { ContentResolver.setSyncAutomatically(account.getAccount(), OVirtContract.CONTENT_AUTHORITY, syncEnabled); if (syncEnabled) { long intervalInSeconds = environmentStore.getSharedPreferencesHelper(account).getPeriodicSyncInterval() * (long) Constants.SECONDS_IN_MINUTE; ContentResolver.addPeriodicSync(account.getAccount(), authority, bundle, intervalInSeconds); } else { ContentResolver.removePeriodicSync(account.getAccount(), authority, bundle); } } catch (AccountDeletedException ignored) { } }
Example 5
Source File: PredatorSyncAdapter.java From Capstone-Project with MIT License | 5 votes |
public static void removePeriodicSync(Context context) { // Disable Sync ContentResolver.setIsSyncable(PredatorAccount.getAccount(context), Constants.Authenticator.PREDATOR_ACCOUNT_TYPE, Constants.Sync.OFF); Logger.d(TAG, "removePeriodicSync: true"); ContentResolver.removePeriodicSync( PredatorAccount.getAccount(context), Constants.Authenticator.PREDATOR_ACCOUNT_TYPE, Bundle.EMPTY); }
Example 6
Source File: SyncCard.java From narrate-android with Apache License 2.0 | 4 votes |
private void enableSync() { Account acc = User.getAccount(); ContentResolver.setIsSyncable(acc, Contract.AUTHORITY, 1); ContentResolver.setSyncAutomatically(acc, Contract.AUTHORITY, true); ContentResolver.removePeriodicSync(acc, Contract.AUTHORITY, Bundle.EMPTY); long interval = Settings.getAutoSyncInterval(); if (interval > 0) { ContentResolver.addPeriodicSync(acc, Contract.AUTHORITY, Bundle.EMPTY, interval); } Bundle b = new Bundle(); b.putBoolean("resync_files", true); SyncHelper.requestManualSync(acc, b); Toast.makeText(GlobalApplication.getAppContext(), GlobalApplication.getAppContext().getString(R.string.data_resyncing), Toast.LENGTH_SHORT).show(); }
Example 7
Source File: SystemSyncContentResolverDelegate.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void removePeriodicSync(Account account, String authority, Bundle extras) { ContentResolver.removePeriodicSync(account, authority, extras); }
Example 8
Source File: QuickSettings.java From haxsync with GNU General Public License v2.0 | 4 votes |
@Override protected Void doInBackground(Void... params) { SharedPreferences prefs = context.getSharedPreferences(context.getPackageName() + "_preferences", Context.MODE_MULTI_PROCESS); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("sync_events", eventSync); editor.putBoolean("sync_birthdays", birthdaySync); editor.putBoolean("sync_contact_birthday", birthdaySync); editor.putBoolean("birthday_reminders", reminders); editor.putBoolean("event_reminders", reminders); if (contactChoice == 1){ editor.putBoolean("phone_only", true); } else if (contactChoice == 2){ editor.putBoolean("phone_only", false); } editor.commit(); Account account = DeviceUtil.getAccount(context); long seconds = prefs.getLong("sync_seconds", 86400); if (birthdaySync || eventSync){ ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, true); ContentResolver.addPeriodicSync(account, CalendarContract.AUTHORITY, new Bundle(), seconds); }else{ ContentResolver.setSyncAutomatically(account, CalendarContract.AUTHORITY, false); ContentResolver.removePeriodicSync(account, CalendarContract.AUTHORITY, new Bundle()); } if (contactChoice > 0){ ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true); ContentResolver.addPeriodicSync(account, ContactsContract.AUTHORITY, new Bundle(), seconds); }else{ ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, false); ContentResolver.removePeriodicSync(account, ContactsContract.AUTHORITY, new Bundle()); } return null; }
Example 9
Source File: Upgrader.java From cathode with Apache License 2.0 | 4 votes |
public static void upgrade(Context context) { final int currentVersion = Settings.get(context).getInt(SETTINGS_VERSION, -1); if (currentVersion == -1) { Settings.get(context) .edit() .putInt(SETTINGS_VERSION, VERSION) .putInt(Settings.VERSION_CODE, BuildConfig.VERSION_CODE) .apply(); return; } if (currentVersion < VERSION) { if (currentVersion < 1) { if (TraktLinkSettings.isLinked(context)) { Account account = Accounts.getAccount(context); ContentResolver.removePeriodicSync(account, BuildConfig.PROVIDER_AUTHORITY, new Bundle()); ContentResolver.setSyncAutomatically(account, BuildConfig.PROVIDER_AUTHORITY, false); ContentResolver.setIsSyncable(account, BuildConfig.PROVIDER_AUTHORITY, 0); } } if (currentVersion < 2) { Settings.get(context) .edit() .remove("suggestions") .remove("lastSyncHidden") .remove("lastPurge") .remove("tmdbLastConfigurationUpdate") .apply(); } if (currentVersion < 3) { TraktTimestamps.getSettings(context).edit().remove(TraktTimestamps.EPISODE_RATING).apply(); } if (currentVersion < 4) { boolean linked = Settings.get(context).getBoolean(TraktLinkSettings.TRAKT_LINKED, false); if (linked) { Settings.get(context) .edit() .putBoolean(TraktLinkSettings.TRAKT_LINK_PROMPTED, true) .apply(); } } if (currentVersion < 6) { TraktTimestamps.clear(context); } Settings.get(context).edit().putInt(SETTINGS_VERSION, VERSION).apply(); } Settings.get(context).edit().putInt(Settings.VERSION_CODE, BuildConfig.VERSION_CODE).apply(); }