Example usage for android.content ContentResolver SYNC_EXTRAS_FORCE

List of usage examples for android.content ContentResolver SYNC_EXTRAS_FORCE

Introduction

In this page you can find the example usage for android.content ContentResolver SYNC_EXTRAS_FORCE.

Prototype

String SYNC_EXTRAS_FORCE

To view the source code for android.content ContentResolver SYNC_EXTRAS_FORCE.

Click Source Link

Usage

From source file:com.alphabetbloc.accessmrs.services.SyncManager.java

public static void syncData() {
    if (App.DEBUG)
        Log.v(TAG, "SyncData is Requested");
    AccountManager accountManager = AccountManager.get(App.getApp());
    Account[] accounts = accountManager.getAccountsByType(App.getApp().getString(R.string.app_account_type));
    if (accounts.length > 0) {

        sStartSync.set(true);/*  w ww .j  av a2 s  .  com*/

        Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);

        // //this resets the scheduled sync
        ContentResolver.requestSync(accounts[0], App.getApp().getString(R.string.app_provider_authority),
                bundle);
    } else
        UiUtils.toastAlert(App.getApp().getString(R.string.sync_error),
                App.getApp().getString(R.string.no_account_setup));
}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

@Override
public void onSyncEnding(SyncContext context, boolean success) {
    final ContentResolver cr = getContext().getContentResolver();

    if (success && mPerformedGetServerDiffs && !mSyncCanceled) {
        Cursor cursor = cr.query(Photos.CONTENT_URI,
                new String[] { Photos._SYNC_ID, Photos._SYNC_VERSION, Photos.PERSON_ID,
                        Photos.DOWNLOAD_REQUIRED },
                "" + "_sync_account=? AND download_required != 0", new String[] { getAccount() }, null);
        try {/*from  ww  w  .j  a v a 2  s  . c o m*/
            if (cursor.getCount() != 0) {
                Bundle extras = new Bundle();
                extras.putString(ContentResolver.SYNC_EXTRAS_ACCOUNT, getAccount());
                extras.putBoolean(ContentResolver.SYNC_EXTRAS_FORCE, mSyncForced);
                extras.putString("feed", ContactsSyncAdapter.getPhotosFeedForAccount(getAccount()));
                getContext().getContentResolver().startSync(Contacts.CONTENT_URI, extras);
            }
        } finally {
            cursor.close();
        }
    }

    super.onSyncEnding(context, success);
}