List of usage examples for android.content ContentResolver requestSync
public static void requestSync(Account account, String authority, Bundle extras)
From source file:Main.java
public static void setServiceSync(String Authority, boolean on, android.accounts.Account account) { ContentResolver.setSyncAutomatically(account, Authority, on); if (on)//from ww w . j a va 2 s.co m ContentResolver.requestSync(account, Authority, new Bundle()); }
From source file:com.clearcenter.mobile_demo.mdStatusActivity.java
public void resetData() { int count = getContentResolver().delete(mdDeviceSamples.CONTENT_URI, mdDeviceSamples.NICKNAME + " = ?", new String[] { account_nickname }); Log.d(TAG, "Reset database, purged " + count + " rows."); bw_graphview.reset();/* w w w. jav a 2s. co m*/ bw_graphview.update(); loadavg_graphview.reset(); loadavg_graphview.update(); mem_graphview.reset(); mem_graphview.update(); ContentResolver resolver = getContentResolver(); final Account account = new Account(account_nickname, mdConstants.ACCOUNT_TYPE); resolver.requestSync(account, mdContentProvider.AUTHORITY, new Bundle()); }
From source file:com.clearcenter.mobile_demo.mdStatusActivity.java
public boolean onOptionsItemSelected(MenuItem item) { ContentResolver resolver = getContentResolver(); final Account account = new Account(account_nickname, mdConstants.ACCOUNT_TYPE); switch (item.getItemId()) { case R.id.menu_refresh: resolver.requestSync(account, mdContentProvider.AUTHORITY, new Bundle()); return true; case R.id.menu_reset: resetData();/*from w w w . j a va 2s. co m*/ return true; } return false; }
From source file:com.clearcenter.mobile_demo.mdStatusActivity.java
protected void onResume() { super.onResume(); observer = new mdDeviceSamplesObserver(observer_handler, this); ContentResolver resolver = getContentResolver(); resolver.registerContentObserver(mdDeviceSamples.CONTENT_URI, true, observer); updateData();/*ww w.j a v a 2s.co m*/ final Account account = new Account(account_nickname, mdConstants.ACCOUNT_TYPE); resolver.requestSync(account, mdContentProvider.AUTHORITY, new Bundle()); if (android.os.Build.VERSION.SDK_INT >= 11) { List<SyncInfo> syncs = resolver.getCurrentSyncs(); for (SyncInfo info : syncs) { Log.d(TAG, "account: " + info.account.name + ", authority: " + info.authority + ", startTime: " + info.startTime); } } }
From source file:tech.salroid.filmy.syncs.FilmySyncAdapter.java
/** * Helper method to have the sync adapter sync immediately * * @param context The context used to access the account service */// ww w. ja 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); ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority), bundle); }
From source file:inforuh.eventfinder.sync.SyncAdapter.java
public static void startSync(Context context) { Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(getAccount(context), context.getString(R.string.content_authority), bundle); }
From source file:com.manning.androidhacks.hack023.MainActivity.java
public void refresh(View v) { Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); Account account = ((HackApplication) getApplication()).getCurrentAccount(); if (ContentResolver.isSyncPending(account, TodoContentProvider.AUTHORITY)) { ContentResolver.cancelSync(account, TodoContentProvider.AUTHORITY); }// w w w . j a v a 2s . c o m ContentResolver.requestSync(account, TodoContentProvider.AUTHORITY, extras); }
From source file:dev.drsoran.moloko.sync.util.SyncUtils.java
public final static void requestManualSync(Account account) { final Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, true); ContentResolver.requestSync(account, Rtm.AUTHORITY, bundle); }
From source file:io.github.hidroh.materialistic.data.ItemSyncAdapter.java
@UiThread static void initSync(Context context, @Nullable String itemId) { if (!Preferences.Offline.isEnabled(context)) { return;/*from w w w. j a v a2 s . c om*/ } Bundle extras = new Bundle(); if (itemId != null) { extras.putString(ItemSyncAdapter.EXTRA_ID, itemId); } extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); extras.putBoolean(ItemSyncAdapter.EXTRA_CONNECTION_ENABLED, Preferences.Offline.currentConnectionEnabled(context)); extras.putBoolean(ItemSyncAdapter.EXTRA_READABILITY_ENABLED, Preferences.Offline.isReadabilityEnabled(context)); extras.putBoolean(ItemSyncAdapter.EXTRA_COMMENTS_ENABLED, Preferences.Offline.isCommentsEnabled(context)); extras.putBoolean(ItemSyncAdapter.EXTRA_NOTIFICATION_ENABLED, Preferences.Offline.isNotificationEnabled(context)); ContentResolver.requestSync(Application.createSyncAccount(), MaterialisticProvider.PROVIDER_AUTHORITY, extras); }
From source file:dev.drsoran.moloko.sync.util.SyncUtils.java
public final static void requestSettingsOnlySync(Context context, Account account) { if (account != null) { final Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(dev.drsoran.moloko.sync.Constants.SYNC_EXTRAS_ONLY_SETTINGS, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, false); ContentResolver.requestSync(account, Rtm.AUTHORITY, bundle); } else {//ww w . j a v a2s.c om // TODO: Show NoAccountDialogFragment if we use PreferenceFragment context.startActivity(Intents.createNewAccountIntent()); } }