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.activiti.android.platform.provider.transfer.ContentTransferManager.java
public static void requestUpload(Fragment fr, Uri uri, String objectId, int type, String mimetyp) { Cursor cursor = null;/*from w ww . j a va 2s.c o m*/ 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.granita.tasks.TaskListFragment.java
/** * Trigger a synchronization for all accounts. *//*from ww w. ja v a 2s .c om*/ private void doSyncNow() { AccountManager accountManager = AccountManager.get(mAppContext); Account[] accounts = accountManager.getAccounts(); for (Account account : accounts) { // TODO: do we need a new bundle for each account or can we reuse it? Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(account, mAuthority, extras); } }
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 *//*from w w w.ja va 2 s .co 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./* w ww .j a v a 2 s. c o m*/ * * @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 {/*from w w w .ja va 2 s . co 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.quarterfull.newsAndroid.NewsReaderListActivity.java
public void startSync() { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) StartLoginFragment(this); else {/*from w w w. jav a2 s .co m*/ if (!ownCloudSyncService.isSyncRunning()) { new PostDelayHandler(this).stopRunningPostDelayHandler();//Stop pending sync handler Bundle accBundle = new Bundle(); accBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); AccountManager mAccountManager = AccountManager.get(this); Account[] accounts = mAccountManager.getAccounts(); for (Account acc : accounts) if (acc.type.equals(AccountGeneral.ACCOUNT_TYPE)) ContentResolver.requestSync(acc, AccountGeneral.ACCOUNT_TYPE, accBundle); //http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync } else { UpdateButtonLayout(); } } }
From source file:de.luhmer.owncloudnewsreader.NewsReaderListActivity.java
public void startSync() { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null) == null) StartLoginFragment(this); else {// ww w. ja v a 2s . c om try { if (!_ownCloudSyncService.isSyncRunning()) { new PostDelayHandler(this).stopRunningPostDelayHandler();//Stop pending sync handler Bundle accBundle = new Bundle(); accBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); AccountManager mAccountManager = AccountManager.get(this); Account[] accounts = mAccountManager.getAccounts(); for (Account acc : accounts) if (acc.type.equals(AccountGeneral.ACCOUNT_TYPE)) ContentResolver.requestSync(acc, AccountGeneral.ACCOUNT_TYPE, accBundle); //http://stackoverflow.com/questions/5253858/why-does-contentresolver-requestsync-not-trigger-a-sync } else { UpdateButtonLayout(); } } catch (RemoteException e) { e.printStackTrace(); } } }
From source file:com.android.contacts.list.DefaultContactBrowseListFragment.java
/** * Request sync for the Google accounts (not include Google+ accounts) specified by the given * filter.// www.j a va2s .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 {/*from w ww . ja va 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); } }