Example usage for android.content ContentResolver setMasterSyncAutomatically

List of usage examples for android.content ContentResolver setMasterSyncAutomatically

Introduction

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

Prototype

public static void setMasterSyncAutomatically(boolean sync) 

Source Link

Document

Sets the master auto-sync setting that applies to all the providers and accounts.

Usage

From source file:Main.java

public static void toggleSync() {
    ContentResolver.setMasterSyncAutomatically(!isSyncEnabled());

}

From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.SyncAction.java

@Override
protected void performActionOn() {
    new AsyncTask<Void, Void, Void>() {

        @Override//from w w  w . j  a  v  a  2 s .c  o  m
        protected Void doInBackground(Void... args) {
            ContentResolver.setMasterSyncAutomatically(true);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(mClickIntent);
        }
    }.execute();
}

From source file:com.woodblockwithoutco.quickcontroldock.model.impl.actions.SyncAction.java

@Override
protected void performActionOff() {
    new AsyncTask<Void, Void, Void>() {
        @Override// w ww . ja  v  a2s  .  c  o m
        protected Void doInBackground(Void... args) {
            ContentResolver.setMasterSyncAutomatically(false);
            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(mClickIntent);
        }
    }.execute();
}

From source file:de.spiritcroc.syncsettings.Util.java

public static void autoMasterSyncOn() {
    ContentResolver.setMasterSyncAutomatically(true);
}

From source file:de.spiritcroc.syncsettings.Util.java

public static void autoMasterSyncOff() {
    ContentResolver.setMasterSyncAutomatically(false);
}

From source file:de.spiritcroc.syncsettings.Util.java

public static void autoMasterSyncToggle() {
    boolean autoSync = ContentResolver.getMasterSyncAutomatically();
    ContentResolver.setMasterSyncAutomatically(!autoSync);
}

From source file:com.gaba.alex.trafficincidents.MainActivity.java

private Account createSyncAccount() {
    Account appAccount = new Account(mAccountName, mAccountType);
    AccountManager accountManager = AccountManager.get(this);
    if (accountManager.addAccountExplicitly(appAccount, null, null)) {
        ContentResolver.setMasterSyncAutomatically(true);
        ContentResolver.setSyncAutomatically(appAccount, AUTHORITY, true);
    }/* w  w w  .ja  va2  s  . co m*/
    return appAccount;
}

From source file:com.google.android.apps.mytracks.AbstractSendToGoogleActivity.java

/**
 * On spreadsheets permission success. If
 * <p>//from w  ww . j  a v  a 2  s .co m
 * isSendDrive and isDriveEnableSync -> enable sync
 * <p>
 * isSendDrive and isDriveShare -> show {@link ShareTrackDialogFragment}
 * <p>
 * isSendDrive -> start {@link SendDriveActivity}
 * <p>
 * isSendMaps -> start {@link SendMapsActivity}
 * <p>
 * isSendFusionTables -> start {@link SendFusionTablesActivity}
 * <p>
 * isSendSpreadsheets -> start {@link SendSpreadsheetsActivity}
 * <p>
 * else -> start {@link UploadResultActivity}
 */
private void onSpreadsheetsPermissionSuccess() {
    Class<?> next;
    if (sendRequest.isSendDrive()) {
        if (sendRequest.isDriveSync()) {
            PreferencesUtils.setBoolean(this, R.string.drive_sync_key, true);

            // Turn off everything
            SyncUtils.disableSync(this);

            // Turn on sync
            ContentResolver.setMasterSyncAutomatically(true);

            // Enable sync for account
            SyncUtils.enableSync(sendRequest.getAccount());
            return;
        } else if (sendRequest.isDriveShare()) {
            ShareTrackDialogFragment.newInstance(sendRequest.getTrackId()).show(getSupportFragmentManager(),
                    ShareTrackDialogFragment.SHARE_TRACK_DIALOG_TAG);
            return;
        } else {
            next = SendDriveActivity.class;
        }
    } else if (sendRequest.isSendMaps()) {
        next = SendMapsActivity.class;
    } else if (sendRequest.isSendFusionTables()) {
        next = SendFusionTablesActivity.class;
    } else if (sendRequest.isSendSpreadsheets()) {
        next = SendSpreadsheetsActivity.class;
    } else {
        next = UploadResultActivity.class;
    }
    Intent intent = IntentUtils.newIntent(this, next).putExtra(SendRequest.SEND_REQUEST_KEY, sendRequest);
    startActivity(intent);
}

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);
        }//from w  ww.  ja  va2 s  .  c o  m
    }
    mAlertContainer.setVisibility(View.GONE);
}

From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java

final static public boolean setAutoSyncEnabled(TaskManagerParms taskMgrParms, EnvironmentParms envParms,
        CommonUtilities util, TaskResponse taskResponse, ActionResponse ar) {
    if (!ContentResolver.getMasterSyncAutomatically()) {
        ContentResolver.setMasterSyncAutomatically(true);
        return true;
    } else {/*w  w w. j  a  va  2s . c om*/
        ar.action_resp = ActionResponse.ACTION_WARNING;
        ar.resp_msg_text = "AutoSync was already enabled, action ignored";
        return false;
    }
}