List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:com.oscarsalguero.solartracker.MainActivity.java
private void updateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { // Update the value of mRequestingLocationUpdates from the Bundle, and // make sure that the Start Updates and Stop Updates buttons are // correctly enabled or disabled. if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY); }//from w w w .jav a2 s. c om // Update the value of mCurrentLocation from the Bundle and update the // UI to show the correct latitude and longitude. if (savedInstanceState.keySet().contains(LOCATION_KEY)) { // Since LOCATION_KEY was found in the Bundle, we can be sure that // mCurrentLocationis not null. mLastLocation = savedInstanceState.getParcelable(LOCATION_KEY); } // Update the value of mLastUpdateTime from the Bundle and update the UI. if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY); } } }
From source file:elbauldelprogramador.com.gpsqr.MapsActivity.java
/** * Updates fields based on data stored in the bundle. * * @param savedInstanceState The activity state saved in the Bundle. *//*from w w w. j a v a 2 s.c o m*/ private void updateValuesFromBundle(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Log.d(TAG, "Updating values from bundle"); } if (savedInstanceState != null) { // Update the value of mLocationsList from the Bundle and update the UI to show the // correct latitude and longitude. if (savedInstanceState.keySet().contains(LOCATION_KEY)) { // Since LOCATION_KEY was found in the Bundle, we can be sure that mLocationsList // is not null. mLocationsList = savedInstanceState.getParcelableArrayList(LOCATION_KEY); mCurrentLocation = mLocationsList.get(mLocationsList.size() - 1); if (mLocationsList.size() >= 2) { mPreviousLocation = mLocationsList.get(mLocationsList.size() - 2); } } } else { mLocationsList = new ArrayList<>(2); } }
From source file:org.akvo.caddisfly.sensor.ec.CalibrateSensorActivity.java
@SuppressWarnings("SameParameterValue") private void startService(Class<?> service, ServiceConnection serviceConnection, @Nullable Bundle extras) { if (!UsbService.SERVICE_CONNECTED) { Intent startService = new Intent(this, service); if (extras != null && !extras.isEmpty()) { Set<String> keys = extras.keySet(); for (String key : keys) { String extra = extras.getString(key); startService.putExtra(key, extra); }//w w w. j a v a2s . com } startService(startService); } Intent bindingIntent = new Intent(this, service); bindService(bindingIntent, serviceConnection, Context.BIND_AUTO_CREATE); deviceStatus = 0; handler.postDelayed(validateDeviceRunnable, 100); }
From source file:org.odk.collect.android.views.ODKView.java
public void setDataForFields(Bundle bundle) throws JavaRosaException { if (bundle == null) { return;/*from w w w . ja va 2s . co m*/ } FormController formController = Collect.getInstance().getFormController(); Set<String> keys = bundle.keySet(); for (String key : keys) { for (QuestionWidget questionWidget : widgets) { FormEntryPrompt prompt = questionWidget.getFormEntryPrompt(); TreeReference treeReference = (TreeReference) prompt.getFormElement().getBind().getReference(); if (treeReference.getNameLast().equals(key)) { switch (prompt.getDataType()) { case Constants.DATATYPE_TEXT: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asStringData(bundle.get(key))); break; case Constants.DATATYPE_INTEGER: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asIntegerData(bundle.get(key))); break; case Constants.DATATYPE_DECIMAL: formController.saveAnswer(prompt.getIndex(), ExternalAppsUtils.asDecimalData(bundle.get(key))); break; default: throw new RuntimeException(getContext().getString(R.string.ext_assign_value_error, treeReference.toString(false))); } break; } } } }
From source file:com.ginstr.android.service.opencellid.upload.data.MeasurementsUploaderService.java
/** * checks intent configuration parameters * @param extras// ww w. j av a 2 s. co m */ private void getExtraParameters(Bundle extras) { if (extras != null) { writeToLog("configurationReceiver.onReceive() extras : " + extras.keySet()); if (extras != null) { appId = extras.getString(UploadConstants.PREF_APPID_KEY); if (extras.containsKey(UploadConstants.PREF_API_KEY)) apiKey = extras.getString(UploadConstants.PREF_API_KEY); if (extras.containsKey(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY)) openCellUrl = extras.getString(UploadConstants.PREF_OPENCELL_UPLOAD_URL_KEY); if (extras.containsKey(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY)) networksUrl = extras.getString(UploadConstants.PREF_OPENCELL_NETWORK_UPLOAD_URL_KEY); testEnvironment = extras.getBoolean(UploadConstants.PREF_TEST_ENVIRONMENT_KEY, UploadConstants.PREF_TEST_ENVIRONMENT); if (openCellUrl == null) { if (testEnvironment) { openCellUrl = UploadConstants.OPEN_CELL_TEST_UPLOAD_URL; } else { openCellUrl = UploadConstants.OPEN_CELL_DEFAULT_UPLOAD_URL; } } if (networksUrl == null) { if (testEnvironment) { networksUrl = UploadConstants.OPENCELL_NETWORKS_TEST_UPLOAD_URL; } else { networksUrl = UploadConstants.OPENCELL_NETWORKS_UPLOAD_URL; } } if (extras.containsKey(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY)) newDataCheckInterval = extras.getLong(UploadConstants.PREF_NEW_DATA_CHECK_INTERVAL_KEY); if (newDataCheckInterval < UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT) newDataCheckInterval = UploadConstants.NEW_DATA_CHECK_INTERVAL_LONG_DEFAULT; if (extras.containsKey(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY)) wifiOnly = extras.getBoolean(UploadConstants.PREF_ONLY_WIFI_UPLOAD_KEY); // check if the maxLogFileSize parameter is provided through intent if (extras.containsKey(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT)) { maxLogFileSize = extras.getInt(UploadConstants.PREFKEY_MAX_LOG_SIZE_INT); mLibContext.getLogService().setMaxLogFileSize(maxLogFileSize); } // check if the logToFileEnabled parameter is provided through intent if (extras.containsKey(UploadConstants.PREFKEY_LOG_TO_FILE)) { logToFileEnabled = extras.getBoolean(UploadConstants.PREFKEY_LOG_TO_FILE); mLibContext.getLogService().setFileLoggingEnabled(logToFileEnabled); } } writeToLog("onConfigurationReceiver ()"); writeToLog("apiKey = " + apiKey); writeToLog("openCellUrl = " + openCellUrl); writeToLog("networks url = " + networksUrl); writeToLog("newDataCheckInterval = " + newDataCheckInterval); writeToLog("wifiOnly = " + wifiOnly); writeToLog("testEnvironment = " + testEnvironment); } }
From source file:istat.android.freedev.pagers.adapters.abs.AbsPagerStateAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/* ww w . j av a2 s . co m*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (int i = 0; i < fss.length; i++) { mSavedState.add((Fragment.SavedState) fss[i]); } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { while (mFragments.size() <= index) { mFragments.add(null); } f.setMenuVisibility(false); mFragments.set(index, f); } else { //Log.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:org.microg.gms.gcm.McsService.java
private void handleSendMessage(Intent intent) { String messageId = intent.getStringExtra(EXTRA_MESSAGE_ID); String collapseKey = intent.getStringExtra(EXTRA_COLLAPSE_KEY); Messenger messenger = intent.getParcelableExtra(EXTRA_MESSENGER); intent.removeExtra(EXTRA_MESSENGER); Parcelable app = intent.getParcelableExtra(EXTRA_APP); String packageName = null;/*from www . ja v a2 s. c om*/ if (app instanceof PendingIntent) { packageName = PackageUtils.packageFromPendingIntent((PendingIntent) app); } if (packageName == null) { Log.w(TAG, "Failed to send message, missing package name"); return; } intent.removeExtra(EXTRA_APP); int ttl; try { ttl = Integer.parseInt(intent.getStringExtra(EXTRA_TTL)); if (ttl < 0 || ttl > maxTtl) { ttl = maxTtl; } } catch (NumberFormatException e) { // TODO: error TtlUnsupported Log.w(TAG, e); return; } String to = intent.getStringExtra(EXTRA_SEND_TO); if (to == null) { // TODO: error missing_to Log.w(TAG, "missing to"); return; } String from = intent.getStringExtra(EXTRA_SEND_FROM); if (from != null) { intent.removeExtra(EXTRA_SEND_FROM); } else { from = intent.getStringExtra(EXTRA_FROM); } if (from == null) { GcmDatabase.Registration reg = database.getRegistration(packageName, PackageUtils.firstSignatureDigest(this, packageName)); if (reg != null) from = reg.registerId; } if (from == null) { Log.e(TAG, "Can't send message, missing from!"); return; } String registrationId = intent.getStringExtra(EXTRA_REGISTRATION_ID); intent.removeExtra(EXTRA_REGISTRATION_ID); List<AppData> appData = new ArrayList<>(); Bundle extras = intent.getExtras(); for (String key : extras.keySet()) { if (!key.startsWith("google.")) { Object val = extras.get(key); if (val instanceof String) { appData.add(new AppData(key, (String) val)); } } } byte[] rawDataArray = intent.getByteArrayExtra("rawData"); ByteString rawData = rawDataArray != null ? ByteString.of(rawDataArray) : null; try { DataMessageStanza msg = new DataMessageStanza.Builder().sent(System.currentTimeMillis() / 1000L) .id(messageId).token(collapseKey).from(from).reg_id(registrationId).to(to).category(packageName) .raw_data(rawData).app_data(appData).build(); send(MCS_DATA_MESSAGE_STANZA_TAG, msg); database.noteAppMessage(packageName, msg.getSerializedSize()); } catch (Exception e) { Log.w(TAG, e); } }
From source file:com.android.mail.utils.FragmentStatePagerAdapter2.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from w w w. j ava 2 s . c o m*/ mFragments.clear(); if (mEnableSavedStates) { Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); if (fss != null) { for (int i = 0; i < fss.length; i++) { mSavedState.add((Fragment.SavedState) fss[i]); } } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { setItemVisible(f, false); mFragments.put(index, f); } else { LogUtils.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:com.mbientlab.metawear.app.CustomFragment.java
private void startService(Class<?> service, ServiceConnection serviceConnection, Bundle extras) { if (!UsbService.SERVICE_CONNECTED) { Intent startService = new Intent(getActivity(), service); if (extras != null && !extras.isEmpty()) { Set<String> keys = extras.keySet(); for (String key : keys) { String extra = extras.getString(key); startService.putExtra(key, extra); }// w ww . j a va2 s . c o m } getActivity().startService(startService); } Intent bindingIntent = new Intent(getActivity(), service); getActivity().bindService(bindingIntent, serviceConnection, Context.BIND_AUTO_CREATE); }
From source file:com.btmura.android.reddit.app.FragmentStateItemPagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from ww w.j a v a2 s. co m*/ mItemIds = bundle.getLongArray("itemIds"); Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (int i = 0; i < fss.length; i++) { mSavedState.add((Fragment.SavedState) fss[i]); } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { while (mFragments.size() <= index) { mFragments.add(null); } f.setMenuVisibility(false); mFragments.set(index, f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }