List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:com.facebook.notifications.internal.asset.AssetManager.java
public AssetManager(@NonNull Parcel parcel) { registeredHandlers = new ConcurrentHashMap<>(); Bundle handlersBundle = parcel.readBundle(getClass().getClassLoader()); for (String type : handlersBundle.keySet()) { registeredHandlers.put(type, (ParcelableAssetHandler) handlersBundle.getParcelable(type)); }// w w w. j a v a 2 s.c o m }
From source file:com.mobilesolutionworks.android.httpcache.WorksHttpCacheService.java
protected void refreshData(Intent intent) { // rebuild into hierarchical uri String local = intent.getStringExtra("local"); String remote = intent.getStringExtra("remote"); if (mQueues.contains(local)) { return;// w ww . j a v a 2 s . c o m } mQueues.add(local); String _method = intent.getStringExtra("method"); WorksHttpRequest.Method method = WorksHttpRequest.Method.GET; if ("POST".equals(_method)) { method = WorksHttpRequest.Method.POST; } WorksHttpRequest config = new WorksHttpRequest(); config.method = method; config.url = remote; Bundle params = intent.getBundleExtra("params"); if (params != null) { for (String key : params.keySet()) { String value = params.getString(key); if (!TextUtils.isEmpty(value)) { config.setPostParam(key, value); } } } int cache = intent.getIntExtra("cache", 0); if (cache == 0) { cache = 60; } cache *= 1000; int timeout = intent.getIntExtra("timeout", 0); if (timeout == 0) { timeout = 10; } timeout *= 1000; WorksHttpFutureTask<String> task = getSaveTask(local, cache, timeout); task.execute(config, mHandler, mExecutors); }
From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java
private void handleExtra(Intent intent) { Bundle extras = intent.getExtras(); if (extras != null && extras.size() > 0) { for (String k : extras.keySet()) { Log.i(TAG, "k = " + k + " : " + extras.getString(k)); }//from w w w. ja v a 2 s . c o m } if (extras != null && "dialog".equals(extras.get("_extra1"))) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle("" + extras.get("_extra2")); alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); } }
From source file:com.google.android.apps.authenticator.dataimport.Importer.java
private boolean tryImportPreferencesFromBundle(Bundle bundle, SharedPreferences preferences) { SharedPreferences.Editor preferencesEditor = preferences.edit(); for (String key : bundle.keySet()) { Object value = bundle.get(key); if (value instanceof Boolean) { preferencesEditor.putBoolean(key, (Boolean) value); } else if (value instanceof Float) { preferencesEditor.putFloat(key, (Float) value); } else if (value instanceof Integer) { preferencesEditor.putInt(key, (Integer) value); } else if (value instanceof Long) { preferencesEditor.putLong(key, (Long) value); } else if (value instanceof String) { preferencesEditor.putString(key, (String) value); } else {/*from w w w.j a v a 2s .co m*/ // Ignore: can only be Set<String> at the moment (API Level 11+), which we don't use anyway. } } return preferencesEditor.commit(); }
From source file:httbdd.cse.nghiatran.halofind.fragment.MainFragment.java
private void updateValuesFromBundle(Bundle savedInstanceState) { if (savedInstanceState != null) { if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) { mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY); }//from w ww . j ava2s . c o m if (savedInstanceState.keySet().contains(LOCATION_KEY)) { } if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) { mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY); } } }
From source file:com.data.pack.Util.java
/** * Connect to an HTTP URL and return the response as a string. * // w w w . j ava 2 s.co m * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url * - the resource to open: must be a welformed URL * @param method * - the HTTP method to use ("GET", "POST", etc.) * @param params * - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String * @throws MalformedURLException * - if the URL format is invalid * @throws IOException * - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Util.logd("Facebook-Util", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:io.ionic.links.IonicDeeplink.java
private JSONObject _bundleToJson(Bundle bundle) { if (bundle == null) { return new JSONObject(); }// w w w . j a v a 2 s. c o m JSONObject j = new JSONObject(); Set<String> keys = bundle.keySet(); for (String key : keys) { try { Class<?> jsonClass = j.getClass(); Class[] cArg = new Class[1]; cArg[0] = String.class; //Workaround for API < 19 try { if (jsonClass.getDeclaredMethod("wrap", cArg) != null) { j.put(key, JSONObject.wrap(bundle.get(key))); } } catch (NoSuchMethodException e) { j.put(key, this._wrap(bundle.get(key))); } } catch (JSONException ex) { } } return j; }
From source file:it.geosolutions.android.map.fragment.GetFeatureInfoFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { // TODO Auto-generated method stub super.onViewCreated(view, savedInstanceState); ListView list = (ListView) getActivity().findViewById(android.R.id.list); Bundle b = getArguments().getBundle("data"); if (b == null) { return;//TODO notify problem }//from w w w. j a v a 2s.co m String[] from = { "name", "value" }; int[] to = { R.id.attribute_name, R.id.attribute_value }; Set<String> layerNameSet = b.keySet(); for (String layerName : layerNameSet) { // Bundle layerBundle = b.getBundle(layerName); ArrayList<Bundle> layerBundleList = b.getParcelableArrayList(layerName); if (layerBundleList != null) { //if some data from the current section int featureListSize = layerBundleList.size(); if (featureListSize != 0) { FeatureSectionAdapter fsa = new FeatureSectionAdapter(); //create a section for every feature for (Bundle feature : layerBundleList) { //Crete an array do display a list of strings... //TODO improve this with a table ArrayList<Map<String, String>> attributeList = new ArrayList<Map<String, String>>(); for (String attributeName : feature.keySet()) { HashMap<String, String> attribute = new HashMap<String, String>(); attribute.put("name", attributeName); attribute.put("value", feature.getString(attributeName)); attributeList.add(attribute); } //tableLayout.addView(adapter.getView(i, null, tableLayout)) Adapter adapter = new SimpleAdapter(view.getContext(), attributeList, R.layout.feature_info_attribute_row, from, to); //new ArrayAdapter<String>(view.getContext(), R.layout.feature_info_header,attributes) fsa.addSection("", adapter); } ; layerSection.addSection(layerName, fsa); } } } // TODO init adapter with headers and data // list.setAdapter(layerSection); }
From source file:com.itude.mobile.mobbl.core.model.MBElement.java
private MBElement(Parcel in) { _values = new HashMap<String, String>(); Bundle valueBundle = in.readBundle(); for (String key : valueBundle.keySet()) { _values.put(key, valueBundle.getString(key)); }//from w w w. j ava 2s . c o m _definition = in.readParcelable(MBElementDefinition.class.getClassLoader()); }
From source file:com.ute.bihapi.wydarzeniatekstowe.thirdScreenActivities.ContactsListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /*if (BuildConfig.DEBUG) { Utils.enableStrictMode();//from w w w .j av a 2 s. c o m }*/ super.onCreate(savedInstanceState); // Set main content view. On smaller screen devices this is a single pane view with one // fragment. One larger screen devices this is a two pane view with two fragments. setContentView(R.layout.activity_contacts_main); // Check if this activity instance has been triggered as a result of a search query. This // will only happen on pre-HC OS versions as from HC onward search is carried out using // an ActionBar SearchView which carries out the search in-line without loading a new // Activity. if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { // Fetch query from intent and notify the fragment that it should display search // results instead of all contacts. String searchQuery = getIntent().getStringExtra(SearchManager.QUERY); ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager() .findFragmentById(R.id.contact_list); // This flag notes that the Activity is doing a search, and so the result will be // search results rather than all contacts. This prevents the Activity and Fragment // from trying to a search on search results. isSearchResultView = true; mContactsListFragment.setSearchQuery(searchQuery); // Set special title for search results String title = getString(R.string.contacts_list_search_results_title, searchQuery); setTitle(title); } memory = new Bundle(); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras != null) { for (String layoutElement : layoutElements) { if (extras.get(layoutElement) != null) { if (layoutElement.equals("Person")) { Bundle mp = null; mp = extras.getBundle("Person"); Log.i("Memory", "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " " + mp.get(mp.keySet().toArray()[0].toString()).toString()); memory.putBundle("Person", mp); } else if (layoutElement.equals("Point")) { Bundle mp = null; mp = extras.getBundle("Point"); Log.i("Memory", "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " " + mp.get(mp.keySet().toArray()[0].toString()).toString()); memory.putBundle("Point", mp); } else { memory.putString(layoutElement, extras.get(layoutElement).toString()); Log.i("Memory", "Got entry from prevoius activity: " + layoutElement + ": " + extras.get(layoutElement).toString()); } } } } } }