List of usage examples for android.content ContentResolver requestSync
public static void requestSync(Account account, String authority, Bundle extras)
From source file:uk.co.bubblebearapps.contactsintegration.MainActivity.java
private void syncAccount(Account account) { // 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); /*//from w w w. ja v a2 s. c o m * Request the sync for the default account, authority, and * manual sync settings */ ContentResolver.requestSync(account, ContactsContract.AUTHORITY, settingsBundle); showMessage("Sync requested, view results in Contacts app"); }
From source file:com.hybris.mobile.app.commerce.CommerceApplicationBase.java
/** * Request a sync of the catalog sync adapter * * @param bundle//from w w w . ja va2s . com */ public static void requestCatalogSyncAdapter(Bundle bundle) { bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); ContentResolver.requestSync( new Account(mInstance.getString(R.string.account_name), mInstance.getString(R.string.account_type)), mInstance.getString(R.string.provider_authority), bundle); }
From source file:com.beesham.popularmovies.sync.MoviesSyncAdapter.java
public static void syncImmediately(Context context) { Bundle b = new Bundle(); b.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); b.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority), b); }
From source file:org.enbyted.android.zseinfo.view.activity.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { BaseSection currentSection = pagerAdapter.getSection(getSupportActionBar().getSelectedTab().getPosition()); switch (item.getItemId()) { case R.id.action_refresh: { if (currentSection.isRefreshActive()) { currentSection.onRefreshPressed(); }/*from w w w .j a va 2 s . c o m*/ break; } case android.R.id.home: { if (currentSection.isBackActive()) { currentSection.onBackPressed(); } break; } case R.id.action_settings: { Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); break; } case R.id.action_about: { Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); break; } case R.id.action_synchronise: { Toast.makeText(this, "Rozpoczynanie synchronizacji.", Toast.LENGTH_LONG).show(); Bundle extras = new Bundle(); extras.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); extras.putBoolean("config", true); extras.putBoolean("replacements", true); extras.putBoolean("timetables", true); ContentResolver.requestSync(account, AUTHORITY, extras); break; } } return false; }
From source file:com.gaba.alex.trafficincidents.MainActivity.java
private void refresh() { Bundle settingsBundle = new Bundle(); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle); }
From source file:com.jasonmheim.rollout.station.CoreContentProvider.java
@Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { StationDataCursor cursor = new StationDataCursor(); if (stationList == null) { Log.i("Rollout", "Provider not yet initialized, checking local storage..."); stationList = stationDataStorage.get(); }/*from w ww .j a v a 2s. c o m*/ if (stationList == null) { Log.i("Rollout", "Local storage was empty."); Future<StationList> future = executorService.submit(stationListDownloader); try { StationList providerList = future.get(); if (providerList == null) { Log.i("Rollout", "Station list failed to download from query, requesting sync"); Bundle settingsBundle = new Bundle(); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); ContentResolver.requestSync(ACCOUNT, AUTHORITY, settingsBundle); } else { Log.i("Rollout", "Direct download succeeded."); // This implicitly sets stationList internalInsert(providerList); } } catch (InterruptedException ex) { Log.w("Rollout", "Content provider sync was interrupted", ex); } catch (ExecutionException ex) { Log.w("Rollout", "Content provider sync execution failed", ex); } } if (stationList != null) { cursor.setStationDataJson(gson.toJson(stationList)); } cursor.setNotificationUri(getContext().getContentResolver(), Constants.STATION_URI); return cursor; }
From source file:org.gots.ui.BaseGotsActivity.java
protected void onRefresh(String AUTHORITY) { if (AUTHORITY == null || "".equals(AUTHORITY)) { Log.d(TAG, "You call onRefresh without Content Resolver Authority"); return;//from w w w.j a v a 2s . co m } Account userAccount = gotsPrefs.getUserAccount(); ContentResolver.setSyncAutomatically(userAccount, AUTHORITY, true); Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(userAccount, AUTHORITY, bundle); }
From source file:p1.nd.khan.jubair.mohammadd.popularmovies.sync.MovieSyncAdapter.java
/** * Method to load more data based on scrolling. * * @param context The context used to load more movie. * @param offset page number to request/load the data. */// ww w .j a v a2 s . c o m public static void loadMoreData(Context context, int offset) { //Log.v("LOG_TAG","loadMoreData:"+offset); Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putInt("page", offset); ContentResolver.requestSync(getSyncAccount(context), context.getString(R.string.content_authority), bundle); }
From source file:de.stkl.gbgvertretungsplan.fragments.MainFragment.java
public void actionRefresh() { // only if neither pending nor active if (!ContentResolver.isSyncActive(((MainActivity) getActivity()).mDefaultAccount, getString(Account.CONTENT_AUTHORITY)) && !ContentResolver.isSyncPending(((MainActivity) getActivity()).mDefaultAccount, getString(Account.CONTENT_AUTHORITY))) { Bundle settingsBundle = new Bundle(); settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); // this is a manual sync settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); // start immediately ContentResolver.requestSync(Authenticator.getDefaultAccount(getActivity()), getString(Account.CONTENT_AUTHORITY), settingsBundle); }//from www . j a v a 2 s. c om }
From source file:com.sintef_energy.ubisolar.activities.DrawerActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); if (requestCode == LOGIN_CALL_ID) { if (resultCode == Activity.RESULT_OK) { Log.v(TAG, "Login was successful. Starting to attain session data."); startFacebookLogin(null);/*from w ww .j ava2 s . c o m*/ // Find the account Account[] accounts = getAccounts(getApplicationContext(), ACCOUNT_TYPE); for (Account account : accounts) { if (account.name.equals(data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME))) { mAccount = account; break; } } if (mAccount == null) { Log.e(TAG, "Account creation somehow failed to make an account."); return; } /* The same as ticking allow sync */ ContentResolver.setSyncAutomatically(mAccount, AUTHORITY_PROVIDER, true); /* Request a sync operation */ Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); //Do sync regardless of settings bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); //Force sync immediately ContentResolver.requestSync(mAccount, AUTHORITY_PROVIDER, bundle); /* Update all -1 users to the current user id. */ AccountManager accountManager = (AccountManager) getApplicationContext() .getSystemService(ACCOUNT_SERVICE); String facebookUID = accountManager.getUserData(mAccount, Global.DATA_FB_UID); ContentValues values = new ContentValues(); values.put(DeviceModel.DeviceEntry.COLUMN_USER_ID, facebookUID); values.put(DeviceModel.DeviceEntry.COLUMN_LAST_UPDATED, System.currentTimeMillis() / 1000L); getContentResolver().update(EnergyContract.Devices.CONTENT_URI, values, EnergyContract.Devices.COLUMN_USER_ID + "=?", new String[] { "-1" }); //Publish a post saying you started using Wattitude RequestManager.getInstance().doFriendRequest().createWallPost( new NewsFeedPost(0, Long.valueOf(facebookUID), 1, System.currentTimeMillis() / 1000), null); } else { Log.v(TAG, "Login failed"); } } }