Example usage for android.content ContentResolver SYNC_EXTRAS_EXPEDITED

List of usage examples for android.content ContentResolver SYNC_EXTRAS_EXPEDITED

Introduction

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

Prototype

String SYNC_EXTRAS_EXPEDITED

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

Click Source Link

Document

If this extra is set to true, the sync request will be scheduled at the front of the sync request queue and without any delay

Usage

From source file:org.voidsink.anewjkuapp.utils.AppUtils.java

public static void triggerSync(Context context, Account account, boolean syncCalendar, boolean syncKusss) {
    try {//from  w w w. j  av  a2 s .  c  o  m
        if (context == null || account == null) {
            return;
        }

        if (syncCalendar || syncKusss) {
            Bundle b = new Bundle();
            // Disable sync backoff and ignore sync preferences. In other
            // words...perform sync NOW!
            b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
            b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
            b.putBoolean(Consts.SYNC_SHOW_PROGRESS, true);

            if (syncCalendar) {
                ContentResolver.requestSync(account, // Sync
                        CalendarContractWrapper.AUTHORITY(), // Calendar Content authority
                        b); // Extras
            }
            if (syncKusss) {
                ContentResolver.requestSync(account, // Sync
                        KusssContentContract.AUTHORITY, // KUSSS Content authority
                        b); // Extras
            }
        }
    } catch (Exception e) {
        Analytics.sendException(context, e, true);
    }
}

From source file:com.synox.android.ui.activity.FileActivity.java

protected void startSynchronization() {
    Log_OC.d(TAG, "Got to start sync");
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) {
        Log_OC.d(TAG, "Canceling all syncs for " + MainApp.getAuthority());
        ContentResolver.cancelSync(null, MainApp.getAuthority());
        // cancel the current synchronizations of any ownCloud account
        Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority());
        ContentResolver.requestSync(getAccount(), MainApp.getAuthority(), bundle);
    } else {//from w  w w.  j a v a 2  s .c  o m
        Log_OC.d(TAG,
                "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority() + " with new API");
        SyncRequest.Builder builder = new SyncRequest.Builder();
        builder.setSyncAdapter(getAccount(), MainApp.getAuthority());
        builder.setExpedited(true);
        builder.setManual(true);
        builder.syncOnce();

        // Fix bug in Android Lollipop when you click on refresh the whole account
        Bundle extras = new Bundle();
        builder.setExtras(extras);

        SyncRequest request = builder.build();
        ContentResolver.requestSync(request);
    }
}

From source file:com.glandorf1.joe.wsprnetviewer.app.sync.WsprNetViewerSyncAdapter.java

/**
 * Helper function to make the adapter sync now.
 *
 * @param context The application context
 */// w  w  w .  ja va  2  s  . c  o m
public static void syncImmediately(Context context) {
    // Pass the settings flags by inserting them in a bundle
    Bundle settingsBundle = new Bundle();
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
    settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
    /*
     * Request the sync for the default account, authority, and manual sync settings
     */
    ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority),
            settingsBundle);
}

From source file:de.azapps.mirakel.main_activity.MainActivity.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    if (this.mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//  w  w  w . jav  a 2  s . c  o  m
    switch (item.getItemId()) {
    case R.id.menu_delete:
        handleDestroyTask(this.currentTask);
        updateShare();
        return true;
    case R.id.menu_move:
        handleMoveTask(this.currentTask);
        return true;
    case R.id.list_delete:
        handleDestroyList(this.currentList);
        return true;
    case R.id.task_sorting:
        this.currentList = ListDialogHelpers.handleSortBy(this, this.currentList, new Helpers.ExecInterface() {
            @Override
            public void exec() {
                setCurrentList(MainActivity.this.currentList);
            }
        }, null);
        return true;
    case R.id.menu_new_list:
        getListFragment().editList(null);
        return true;
    case R.id.menu_sort_lists:
        final boolean t = !item.isChecked();
        getListFragment().enableDrop(t);
        item.setChecked(t);
        return true;
    case R.id.menu_settings:
        final Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
        startActivityForResult(intent, MainActivity.RESULT_SETTINGS);
        break;
    case R.id.menu_contact:
        Helpers.contact(this);
        break;
    case R.id.menu_new_ui:
        MirakelCommonPreferences.setUseNewUI(true);
        Helpers.restartApp(this);
        break;
    case R.id.menu_sync_now:
        final Bundle bundle = new Bundle();
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
        new Thread(new Runnable() {
            @SuppressLint("InlinedApi")
            @Override
            public void run() {
                final List<AccountMirakel> accounts = AccountMirakel.getEnabled(true);
                for (final AccountMirakel a : accounts) {
                    // davdroid accounts should be there only from
                    // API>=14...
                    ContentResolver.requestSync(a.getAndroidAccount(), DefinitionsHelper.AUTHORITY_TYP, bundle);
                }
            }
        }).start();
        break;
    case R.id.share_task:
        SharingHelper.share(this, getCurrentTask());
        break;
    case R.id.share_list:
        SharingHelper.share(this, getCurrentList());
        break;
    case R.id.search:
        onSearchRequested();
        break;
    case R.id.menu_undo:
        UndoHistory.undoLast(this);
        updateCurrentListAndTask();
        if (this.currentPosition == getTaskFragmentPosition()) {
            setCurrentTask(this.currentTask);
        } else if ((getListFragment() != null) && (getTasksFragment() != null)
                && (getListFragment().getAdapter() != null) && (getTasksFragment().getAdapter() != null)) {
            getListFragment().getAdapter().changeData(ListMirakel.all());
            getListFragment().getAdapter().notifyDataSetChanged();
            getTasksFragment().getAdapter().notifyDataSetChanged();
            if (!MirakelCommonPreferences.isTablet()
                    && (this.currentPosition == MainActivity.getTasksFragmentPosition())) {
                setCurrentList(getCurrentList());
            }
        }
        break;
    case R.id.mark_as_subtask:
        TaskDialogHelpers.handleSubtask(this, this.currentTask, null, true);
        break;
    case R.id.menu_task_clone:
        try {
            final Task newTask = this.currentTask.create();
            setCurrentTask(newTask, true);
            getListFragment().update();
            updatesForTask(newTask);
        } catch (final NoSuchListException e) {
            Log.wtf(MainActivity.TAG, "List vanished on task cloning");
        }
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}