List of usage examples for android.content ContentResolver setSyncAutomatically
public static void setSyncAutomatically(Account account, String authority, boolean sync)
From source file:com.rowland.hashtrace.sync.TweetHashTracerSyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { /*// w w w.j av a2s.co m * Since we've created an account */ TweetHashTracerSyncAdapter.configurePeriodicSync(context, SYNC_INTERVAL, SYNC_FLEXTIME); /* * Without calling setSyncAutomatically, our periodic sync will not be * enabled. */ ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); /* * Finally, let's do a sync to get things started */ syncImmediately(context); }
From source file:co.carlosjimenez.android.currencyalerts.app.sync.ForexSyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { // Interval at which to sync with the rates, in seconds. // 60 seconds (1 minute) * 180 = 3 hours int syncFrequency = Utility.getSyncFrequency(context); if (syncFrequency != -1) { int syncInterval = 60 * syncFrequency; int syncFlextime = syncInterval / 3; ForexSyncAdapter.configurePeriodicSync(context, syncInterval, syncFlextime); }/* w w w. j av a 2s. co m*/ /* * Without calling setSyncAutomatically, our periodic sync will not be enabled. */ ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); /* * Finally, let's do a sync to get things started */ syncImmediately(context); }
From source file:de.spiritcroc.syncsettings.Util.java
public static void autoSyncToggle(Account account, String authority) { if (DEBUG) {//from w w w . java 2 s.c om Log.d(LOG_TAG, "sync toggle " + account + ", " + authority); Log.d(LOG_TAG, "previous " + ContentResolver.getSyncAutomatically(account, authority)); } boolean autoSync = ContentResolver.getSyncAutomatically(account, authority); ContentResolver.setSyncAutomatically(account, authority, !autoSync); if (DEBUG) { Log.d("syncsettings", "now " + ContentResolver.getSyncAutomatically(account, authority)); } }
From source file:com.katamaditya.apps.weather4u.weathersync.Weather4USyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { /*//from w w w . j a v a 2s . c om * Since we've created an account */ Weather4USyncAdapter.configurePeriodicSync(context, SYNC_INTERVAL, SYNC_FLEXTIME); /* * Without calling setSyncAutomatically, our periodic sync will not be enabled. */ ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); /* * Finally, let's do a sync to get things started */ syncImmediately(context); }
From source file:org.sufficientlysecure.keychain.service.ContactSyncAdapterService.java
public static void enableContactsSync(Context context) { Account account = KeychainApplication.createAccountIfNecessary(context); if (account == null) { return;//from w ww.j a va2 s .com } ContentResolver.setIsSyncable(account, ContactsContract.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, ContactsContract.AUTHORITY, true); }
From source file:com.granita.contacticloudsync.syncadapter.AccountSettings.java
public void setSyncInterval(String authority, long seconds) { if (seconds == SYNC_INTERVAL_MANUALLY) { ContentResolver.setSyncAutomatically(account, authority, false); } else {//from w w w.ja va2s . co m ContentResolver.setSyncAutomatically(account, authority, true); ContentResolver.addPeriodicSync(account, authority, new Bundle(), seconds); } }
From source file:com.pindroid.authenticator.AuthenticatorActivity.java
/** * // w ww .j a va2s . c om * Called when response is received from the server for authentication * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. Also sets * the authToken in AccountManager for this account. * * @param the confirmCredentials result. */ protected void finishLogin(String authToken) { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); final int synctime = Integer.parseInt(settings.getString("pref_synctime", "0")); final Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); if (mRequestNewAccount) { mAccountManager.addAccountExplicitly(account, null, null); ContentResolver.setSyncAutomatically(account, BookmarkContentProvider.AUTHORITY, true); if (synctime != 0) { SyncUtils.addPeriodicSync(BookmarkContentProvider.AUTHORITY, Bundle.EMPTY, synctime, this); } } mAccountManager.setAuthToken(account, Constants.AUTHTOKEN_TYPE, authToken); final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, Constants.ACCOUNT_TYPE); intent.putExtra(AccountManager.KEY_AUTHTOKEN, authToken); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:at.bitfire.davdroid.AccountSettings.java
public void setSyncInterval(@NonNull String authority, long seconds) { if (seconds == SYNC_INTERVAL_MANUALLY) { ContentResolver.setSyncAutomatically(account, authority, false); } else {//from w ww .j a va 2 s.co m ContentResolver.setSyncAutomatically(account, authority, true); ContentResolver.addPeriodicSync(account, authority, new Bundle(), seconds); } }
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java
/** * Called when response is received from the server for authentication * request. See onAuthenticationResult(). Sets the * AccountAuthenticatorResult which is sent back to the caller. We store the * authToken that's returned from the server as the 'password' for this * account - so we're never storing the user's actual password locally. * * @param result the confirmCredentials result. */// w w w . java 2 s . c o m private void finishLogin(String authToken) { Log.i(TAG, "finishLogin()"); final Account account = new Account(mUsername, GMSApplication.ACCOUNT_TYPE); if (mIsUnknownAccountName) { mAccountManager.addAccountExplicitly(account, mPassword, null); // Set contacts sync for this account. ContentResolver.setIsSyncable(account, GMSProvider.AUTHORITY, 1); ContentResolver.setSyncAutomatically(account, GMSProvider.AUTHORITY, true); } else { mAccountManager.setPassword(account, mPassword); } final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mUsername); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, GMSApplication.ACCOUNT_TYPE); setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); finish(); }
From source file:com.skywomantechnology.app.guildviewer.sync.GuildViewerSyncAdapter.java
/** * Configure a periodic sync of the data then Sync data immediately. * Display a Toast message to let the user know what is happening. * * @param newAccount/*from w ww . ja v a 2 s. c o m*/ * account to configure sync on * @param context * current application environment context */ private static void onAccountCreated(Account newAccount, Context context) { configurePeriodicSync(context, SYNC_INTERVAL, SYNC_FLEXTIME); ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); // sync the initial data syncImmediately(context); Toast.makeText(context, context.getString(R.string.toast_retrieving_data_message), Toast.LENGTH_LONG) .show(); }