List of usage examples for android.content ContentResolver setSyncAutomatically
public static void setSyncAutomatically(Account account, String authority, boolean sync)
From source file:com.ravi.apps.android.newsbytes.sync.NewsSyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { // Configure the sync. NewsSyncAdapter.configurePeriodicSync(context, SYNC_INTERVAL, SYNC_FLEXTIME); // Enable periodic sync. ContentResolver.setSyncAutomatically(newAccount, context.getString(R.string.content_authority), true); // Trigger an immediate sync to get the ball rolling! syncImmediately(context);//from w w w .j av a 2 s. c o m }
From source file:com.upenn.chriswang1990.sunshine.sync.SunshineSyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { /*//from w ww .ja va 2s . c o m * Since we've created an account */ SunshineSyncAdapter.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); }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
private void turnSyncOn() { final ContactListFilter filter = getFilter(); if (filter.filterType == ContactListFilter.FILTER_TYPE_ACCOUNT && mReasonSyncOff == SyncUtil.SYNC_SETTING_ACCOUNT_SYNC_OFF) { ContentResolver.setSyncAutomatically(new Account(filter.accountName, filter.accountType), ContactsContract.AUTHORITY, true); mAlertContainer.setVisibility(View.GONE); } else {//from w w w .j a v a 2 s . c om final EnableGlobalSyncDialogFragment dialog = new EnableGlobalSyncDialogFragment(); dialog.show(this, filter); } }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
@Override public void onEnableAutoSync(ContactListFilter filter) { // Turn on auto-sync ContentResolver.setMasterSyncAutomatically(true); // This should be OK (won't block) because this only happens after a user action final List<AccountInfo> accountInfos = Futures.getUnchecked(mWritableAccountsFuture); // Also enable Contacts sync final List<AccountWithDataSet> accounts = AccountInfo.extractAccounts(accountInfos); final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts); if (syncableAccounts != null && syncableAccounts.size() > 0) { for (Account account : syncableAccounts) { ContentResolver.setSyncAutomatically(new Account(account.name, account.type), ContactsContract.AUTHORITY, true); }//w w w . ja v a 2s .co m } mAlertContainer.setVisibility(View.GONE); }
From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java
private void createAccount() { final Context context = this; new SilentBackgroundTask<Void>(this) { @Override/* w ww . j av a2 s .co m*/ protected Void doInBackground() throws Throwable { AccountManager accountManager = (AccountManager) context.getSystemService(ACCOUNT_SERVICE); Account account = new Account(Constants.SYNC_ACCOUNT_NAME, Constants.SYNC_ACCOUNT_TYPE); accountManager.addAccountExplicitly(account, null, null); SharedPreferences prefs = Util.getPreferences(context); boolean syncEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_ENABLED, true); int syncInterval = Integer.parseInt(prefs.getString(Constants.PREFERENCES_KEY_SYNC_INTERVAL, "60")); // Add enabled/frequency to playlist/podcasts syncing ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, syncEnabled); ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PLAYLIST_AUTHORITY, new Bundle(), 60L * syncInterval); ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, syncEnabled); ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_PODCAST_AUTHORITY, new Bundle(), 60L * syncInterval); // Add for starred/recently added ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_STARRED_AUTHORITY, (syncEnabled && prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_STARRED, false))); ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_STARRED_AUTHORITY, new Bundle(), 60L * syncInterval); ContentResolver.setSyncAutomatically(account, Constants.SYNC_ACCOUNT_MOST_RECENT_AUTHORITY, (syncEnabled && prefs.getBoolean(Constants.PREFERENCES_KEY_SYNC_MOST_RECENT, false))); ContentResolver.addPeriodicSync(account, Constants.SYNC_ACCOUNT_MOST_RECENT_AUTHORITY, new Bundle(), 60L * syncInterval); return null; } @Override protected void done(Void result) { } }.execute(); }
From source file:com.glandorf1.joe.wsprnetviewer.app.sync.WsprNetViewerSyncAdapter.java
private static void onAccountCreated(Account newAccount, Context context) { // Schedule the sync for periodic execution WsprNetViewerSyncAdapter.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); // Let's do a sync to get things started. syncImmediately(context);//ww w . j a v a 2s. co m }