List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:andlabs.lounge.service.LoungeServiceImpl.java
private void sendMessage(String pType, String pPackageId, String pMatchId, Bundle pMoveBundle) { try {//from w w w . ja v a 2 s. com // PAYLOAD { gameID: packageID?, matchID: matchID?, move: {... } } JSONObject payload = new JSONObject().put("gameID", pPackageId).put("matchID", pMatchId); JSONObject bundleJson = new JSONObject(); for (String key : pMoveBundle.keySet()) { bundleJson.put(key, pMoveBundle.get(key)); } payload.put("move", bundleJson.toString()); mSocketIO.emit(pType, payload); } catch (JSONException e) { Ln.e(e, pType + "(): caught exception while sending move"); } }
From source file:com.iStudy.Study.Renren.Util.java
private static HttpURLConnection sendFormdata(String reqUrl, Bundle parameters, String fileParamName, String filename, String contentType, byte[] data) { HttpURLConnection urlConn = null; try {/*from w w w . jav a2 s. c om*/ URL url = new URL(reqUrl); urlConn = (HttpURLConnection) url.openConnection(); urlConn.setRequestMethod("POST"); urlConn.setConnectTimeout(5000);// ??jdk urlConn.setReadTimeout(5000);// ??jdk 1.5??,? urlConn.setDoOutput(true); urlConn.setRequestProperty("connection", "keep-alive"); String boundary = "-----------------------------114975832116442893661388290519"; // urlConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); boundary = "--" + boundary; StringBuffer params = new StringBuffer(); if (parameters != null) { for (Iterator<String> iter = parameters.keySet().iterator(); iter.hasNext();) { String name = iter.next(); String value = parameters.getString(name); params.append(boundary + "\r\n"); params.append("Content-Disposition: form-data; name=\"" + name + "\"\r\n\r\n"); // params.append(URLEncoder.encode(value, "UTF-8")); params.append(value); params.append("\r\n"); } } StringBuilder sb = new StringBuilder(); sb.append(boundary); sb.append("\r\n"); sb.append("Content-Disposition: form-data; name=\"" + fileParamName + "\"; filename=\"" + filename + "\"\r\n"); sb.append("Content-Type: " + contentType + "\r\n\r\n"); byte[] fileDiv = sb.toString().getBytes(); byte[] endData = ("\r\n" + boundary + "--\r\n").getBytes(); byte[] ps = params.toString().getBytes(); OutputStream os = urlConn.getOutputStream(); os.write(ps); os.write(fileDiv); os.write(data); os.write(endData); os.flush(); os.close(); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } return urlConn; }
From source file:com.andorn.powertask.adapters.CustomFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);// ww w. j a v a 2 s . c o 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); } mFragments.set(index, f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:jahirfiquitiva.iconshowcase.fragments.base.FragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from w w w . j av a2 s . com*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (Parcelable fs : fss) { mSavedState.add((Fragment.SavedState) fs); } } 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); } } } } }
From source file:com.edicon.firebase.devs.firepix.GeoFireFragment.java
/** * Updates fields based on data stored in the bundle. * @param savedInstanceState The activity state saved in the Bundle. *///w w w . ja v a 2s . c o m private void updateValuesFromBundle(Bundle savedInstanceState) { Log.i(TAG, "Updating values from bundle"); if (savedInstanceState != null) { // Update the value of currentLocation from the Bundle and update the UI to show the // correct latitude and longitude. if (savedInstanceState.keySet().contains(MyLocation.LOCATION_KEY)) { // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation // is not null. MyLocation.currentLocation = savedInstanceState.getParcelable(MyLocation.LOCATION_KEY); } // Update the value of mLastUpdateTime from the Bundle and update the UI. if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) { MyLocation.lastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY); } //updateUI(); } }
From source file:com.example.study.studyproject.adapter.FragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);// w ww. j ava 2 s .c o 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 { } } } } }
From source file:cl.monsoon.s1next.widget.FragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from w ww.java2s . c o m*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (Parcelable fs : fss) { mSavedState.add((Fragment.SavedState) fs); } } 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:com.facebook.android.FBUtil.java
/** * Connect to an HTTP URL and return the response as a string. * * 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//w ww . ja va 2 s. c om * @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; // Try to get filename key String filename = params.getString("filename"); // If found if (filename != null) { // Remove from params params.remove("filename"); } if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-FBUtil", 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=\"" + ((filename) != null ? 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:com.audiokernel.euphonyrmt.library.SimpleLibraryActivity.java
private String debugIntent(final Intent intent) { final ComponentName callingActivity = getCallingActivity(); final StringBuilder stringBuilder = new StringBuilder(); final Bundle extras = intent.getExtras(); stringBuilder.append("SimpleLibraryActivity started with invalid extra"); if (callingActivity != null) { stringBuilder.append(", calling activity: "); stringBuilder.append(callingActivity.getClassName()); }/*from w w w.j av a2 s .c o m*/ if (extras != null) { for (final String what : extras.keySet()) { stringBuilder.append(", intent extra: "); stringBuilder.append(what); } } stringBuilder.append('.'); return stringBuilder.toString(); }
From source file:com.klinker.android.launcher.addons.pages.FragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);//from w w w. ja v a 2 s . c o 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)); try { 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); } } catch (IllegalStateException e) { // fragment no longer exists } } } } }