List of usage examples for android.content ContentResolver SYNC_EXTRAS_EXPEDITED
String SYNC_EXTRAS_EXPEDITED
To view the source code for android.content ContentResolver SYNC_EXTRAS_EXPEDITED.
Click Source Link
From source file:com.adkdevelopment.earthquakesurvival.data.syncadapter.SyncAdapter.java
/** * Helper method to have the sync adapter sync immediately * * @param context The context used to access the account service *//*from ww w . java 2 s .c o m*/ public static void syncImmediately(Context context) { Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.sync_provider_authority), bundle); }
From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static void requestUpload(Fragment fr, Uri uri, String objectId, int type, String mimetyp) { Cursor cursor = null;/* ww w. j av a2 s . com*/ String name = null, source, sourceId, mimetype = mimetyp; try { Bundle settingsBundle = new Bundle(); // Retrieve other info cursor = fr.getActivity().getContentResolver().query(uri, null, null, null, null); if (cursor == null && uri != null) { // Is it a file ? File file = new File(uri.getPath()); if (file.exists()) { // It's a file name = file.getName(); settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_CONTENT_PATH, file.getPath()); if (mimetype == null) { MimeType mime = MimeTypeManager.getInstance(fr.getActivity()).getMimetype(file.getName()); mimetype = (mime != null) ? mime.getMimeType() : mimetyp; } } } else if (cursor != null && cursor.moveToFirst()) { name = cursor.getString(cursor.getColumnIndex(DocumentsContract.Document.COLUMN_DISPLAY_NAME)); mimetype = cursor.getString(cursor.getColumnIndex(DocumentsContract.Document.COLUMN_MIME_TYPE)); settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_CONTENT_URI, uri.toString()); } else { throw new Exception("Cursor is empty"); } settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); settingsBundle.putInt(ContentTransferSyncAdapter.ARGUMENT_MODE, ContentTransferSyncAdapter.MODE_SAF_UPLOAD); settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_FILE_PATH, name); if (type == TYPE_TASK_ID) { settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_TASK_ID, objectId); } else if (type == TYPE_PROCESS_ID) { settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_PROCESS_ID, objectId); } else if (type == TYPE_PROFILE_ID) { settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_PROFILE_ID, objectId); } settingsBundle.putString(ContentTransferSyncAdapter.ARGUMENT_MIMETYPE, mimetype); ContentResolver.requestSync( ActivitiAccountManager.getInstance(fr.getActivity()).getCurrentAndroidAccount(), ContentTransferProvider.AUTHORITY, settingsBundle); } catch (Exception e) { Log.w("COntent Transfer", Log.getStackTraceString(e)); } finally { CursorUtils.closeCursor(cursor); } }
From source file:com.upenn.chriswang1990.sunshine.sync.SunshineSyncAdapter.java
/** * Helper method to have the sync adapter sync immediately * * @param context The context used to access the account service *///w w w . j a va 2s. c o m public static void syncImmediately(Context context) { Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); //Set status to no network when net work is not available if (!Utility.isNetworkAvailable(context)) { Utility.setLocationStatus(context, LOCATION_STATUS_NO_NETWORK); } ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority), bundle); }
From source file:com.openerp.MainActivity.java
/** * Request sync./*from w w w .ja va 2 s .c om*/ * * @param authority * the authority * @param bundle * the extra data */ public void requestSync(String authority, Bundle bundle) { Account account = OpenERPAccountManager.getAccount(getApplicationContext(), OEUser.current(getApplicationContext()).getAndroidName()); Bundle settingsBundle = new Bundle(); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); if (bundle != null) { settingsBundle.putAll(bundle); } ContentResolver.requestSync(account, authority, settingsBundle); }
From source file:com.digitalarx.android.ui.activity.FileDisplayActivity.java
private void startSynchronization() { Log_OC.e(TAG, "Got to start sync"); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) { Log_OC.e(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.e(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority()); ContentResolver.requestSync(getAccount(), MainApp.getAuthority(), bundle); } else {/* w w w. j av a 2 s . c o m*/ Log_OC.e(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(); SyncRequest request = builder.build(); ContentResolver.requestSync(request); } }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
/** * Request sync for the Google accounts (not include Google+ accounts) specified by the given * filter.//from w ww . j av a 2 s. c o m */ private void syncContacts(ContactListFilter filter) { if (filter == null) { return; } final Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); final List<AccountWithDataSet> accounts = AccountInfo .extractAccounts(Futures.getUnchecked(mWritableAccountsFuture)); final List<Account> syncableAccounts = filter.getSyncableAccounts(accounts); if (syncableAccounts != null && syncableAccounts.size() > 0) { for (Account account : syncableAccounts) { // We can prioritize Contacts sync if sync is not initialized yet. if (!SyncUtil.isSyncStatusPendingOrActive(account) || SyncUtil.isUnsyncableGoogleAccount(account)) { ContentResolver.requestSync(account, ContactsContract.AUTHORITY, bundle); } } } }
From source file:com.cerema.cloud2.ui.activity.FileDisplayActivity.java
private 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 {/*w w w . ja va 2 s . co 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.hybris.mobile.lib.commerce.provider.CatalogProvider.java
/** * Request a sync (we force it)/* w w w . j a v a 2s . c o m*/ * * @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); }//w w w.ja va 2s.com }