List of usage examples for android.content ContentResolver SYNC_EXTRAS_MANUAL
String SYNC_EXTRAS_MANUAL
To view the source code for android.content ContentResolver SYNC_EXTRAS_MANUAL.
Click Source Link
From source file:com.hybris.mobile.lib.commerce.provider.CatalogProvider.java
/** * Request a sync (we force it)//from w ww .ja va 2 s. c om * * @param bundle extras parameters for the sync */ private void requestSync(Bundle bundle) { if (bundle == null) { bundle = new Bundle(); } Log.i(TAG, "Requesting a sync with bundle: " + bundle.toString()); // Parameters to force the sync without any delay bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); ContentResolver.requestSync(account, authority, bundle); }
From source file:at.bitfire.davdroid.ui.AccountActivity.java
protected static void requestSync(Account account) { String authorities[] = { ContactsContract.AUTHORITY, CalendarContract.AUTHORITY, TaskProvider.ProviderName.OpenTasks.authority }; for (String authority : authorities) { Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); // manual sync extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); // run immediately (don't queue) ContentResolver.requestSync(account, authority, extras); }//from w ww . ja v a 2 s . c o m }
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 a 2s . co 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.owncloud.android.ui.activity.FileDisplayActivity.java
private void startSynchronization() { ContentResolver.cancelSync(null, AccountAuthenticator.AUTHORITY); // cancel // the // current // synchronizations // of // any // ownCloud // account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(getAccount(), AccountAuthenticator.AUTHORITY, bundle); shareDetailsSync();//from w w w. j av a2s . co m }
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 {/*ww w . ja 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 *///from w ww . j a v a 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:com.nononsenseapps.notepad.MainActivity.java
private void requestSync(String accountName) { if (accountName != null && !"".equals(accountName)) { Account account = SyncPrefs.getAccount(AccountManager.get(this), accountName); // Don't start a new sync if one is already going if (!ContentResolver.isSyncActive(account, NotePad.AUTHORITY)) { Bundle options = new Bundle(); // This will force a sync regardless of what the setting is // in accounts manager. Only use it here where the user has // manually desired a sync to happen NOW. options.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(account, NotePad.AUTHORITY, options); }// w w w. j av a 2 s .c o m } }
From source file:de.azapps.mirakel.main_activity.MainActivity.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { if (this.mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w . ja v a 2 s. co 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; }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
/** * Creates a new account through the Account Authenticator that started this * activity./*from w w w . j av a 2 s. c o m*/ * * This makes the account permanent. * * TODO Decide how to name the OAuth accounts */ private boolean createAccount() { // / create and save new ownCloud account boolean isOAuth = AccountAuthenticator.AUTH_TOKEN_TYPE_ACCESS_TOKEN.equals(mAuthTokenType); boolean isSaml = AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE.equals(mAuthTokenType); Uri uri = Uri.parse(mHostBaseUrl); String username = mUsernameInput.getText().toString().trim(); username = username + "@" + location; if (isSaml) { username = getUserNameForSamlSso(); } else if (isOAuth) { username = "OAuth_user" + (new java.util.Random(System.currentTimeMillis())).nextLong(); } String accountName = username + "@" + uri.getHost(); if (uri.getPort() >= 0) { accountName += ":" + uri.getPort(); } mAccount = new Account(accountName, AccountAuthenticator.ACCOUNT_TYPE); if (AccountUtils.exists(mAccount, getApplicationContext())) { // fail - not a new account, but an existing one; disallow RemoteOperationResult result = new RemoteOperationResult(ResultCode.ACCOUNT_NOT_NEW); updateAuthStatusIconAndText(result); showAuthStatus(); Log_OC.d(TAG, result.getLogMessage()); return false; } else { if (isOAuth || isSaml) { mAccountMgr.addAccountExplicitly(mAccount, "", null); // with // external // authorizations, // the // password // is // never // input // in the // app } else { mAccountMgr.addAccountExplicitly(mAccount, mPasswordInput.getText().toString(), null); } // / add the new account as default in preferences, if there is none // already Account defaultAccount = AccountUtils.getCurrentOwnCloudAccount(this); if (defaultAccount == null) { SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit(); editor.putString("select_oc_account", accountName); editor.commit(); } // / prepare result to return to the Authenticator // TODO check again what the Authenticator makes with it; probably // has the same effect as addAccountExplicitly, but it's not well // done final Intent intent = new Intent(); intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, AccountAuthenticator.ACCOUNT_TYPE); intent.putExtra(AccountManager.KEY_ACCOUNT_NAME, mAccount.name); /* * if (!isOAuth) intent.putExtra(AccountManager.KEY_AUTHTOKEN, * AccountAuthenticator.ACCOUNT_TYPE); */ intent.putExtra(AccountManager.KEY_USERDATA, username); if (isOAuth || isSaml) { mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken); } // / add user data to the new account; TODO probably can be done in // the last parameter addAccountExplicitly, or in KEY_USERDATA mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION, mDiscoveredVersion.toString()); mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL, mHostBaseUrl); if (isSaml) { mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); } else if (isOAuth) { mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2, "TRUE"); } setAccountAuthenticatorResult(intent.getExtras()); setResult(RESULT_OK, intent); // / immediately request for the synchronization of the new account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(mAccount, AccountAuthenticator.AUTHORITY, bundle); syncAccount(); // Bundle bundle = new Bundle(); // bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); // ContentResolver.requestSync(mAccount, // AccountAuthenticator.AUTHORITY, bundle); return true; } }
From source file:com.owncloud.android.authentication.AuthenticatorActivity.java
private void syncAccount() { // / immediately request for the synchronization of the new account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(mAccount, AccountAuthenticator.AUTHORITY, bundle); }