List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:de.tudarmstadt.informatik.secuso.phishedu2.MainActivity.java
@Override protected void onCreate(Bundle b) { super.onCreate(b); clearFragCache();//from ww w.ja v a2 s . com if (b != null) { this.current_frag = b.getString("current_frag"); Bundle fragcache_bundle = b.getBundle("fragCache"); Set<String> keyset = fragcache_bundle.keySet(); for (String key : keyset) { try { @SuppressWarnings("unchecked") Class<PhishBaseActivity> fragClass = (Class<PhishBaseActivity>) Class.forName(key); PhishBaseActivity newinstance = fragClass.newInstance(); Bundle current_bundle = fragcache_bundle.getBundle(key); newinstance.onCreate(current_bundle); addToFragCache(newinstance); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } setContentView(R.layout.main); if (!BackendControllerImpl.getInstance().isInitDone()) { BackendControllerImpl.getInstance().init(this, this); } BackendControllerImpl.getInstance().clearOnLevelChangeListener(); BackendControllerImpl.getInstance().clearOnLevelstateChangeListener(); BackendControllerImpl.getInstance().addOnLevelChangeListener(this); BackendControllerImpl.getInstance().addOnLevelstateChangeListener(this); clearFragCache(); showMainMenu(); BackendControllerImpl.getInstance().onUrlReceive(getIntent().getData()); }
From source file:com.github.nutomic.pegasus.LocationService.java
/** * Receive start Intent, start learning an area or check if the * sound profile for the current area has changed. *//* www. j ava2 s . c o m*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { Set<String> keys = extras.keySet(); if (keys.contains(MESSAGE_LEARN_AREA)) { // Set the area to learn now and the learn duration. mLearnUntil = SystemClock.elapsedRealtime() + extras.getLong(MESSAGE_LEARN_INTERVAL); mLearnArea = extras.getLong(MESSAGE_LEARN_AREA); } if (keys.contains(MESSAGE_UPDATE)) { // Profile/area mappings have changed, reapply profile. mCellListener.applyProfile(mCurrentCell); } } } return START_STICKY; }
From source file:com.phonegap.plugins.pdf417.Pdf417Scanner.java
private JSONObject parseUSDL(USDLScanResult p) throws JSONException { JSONObject fields = new JSONObject(); Bundle bundle = p.getData(); for (String key : bundle.keySet()) { // Originaly in RecognitionResultConstants.RECOGNITIONDATA_TYPE if (RECOGNITIONDATA_TYPE.equals(key)) { continue; }// w w w . j av a 2 s .c om Object value = bundle.get(key); if (value instanceof String) { fields.put(key, (String) value); } else { Log.d(LOG_TAG, "Ignoring non string key '" + key + "'"); } } JSONObject result = new JSONObject(); result.put(RESULT_TYPE, "USDL result"); result.put(FIELDS, fields); return result; }
From source file:com.juanojfp.gcmsample.MainActivity.java
private void getExtrasFromIntent(Intent it) { if (it != null && it.getExtras() != null) { Log.e("Intent GCM ", it.getExtras().toString()); Bundle bundle = it.getExtras(); StringBuilder sb = new StringBuilder(); for (String key : bundle.keySet()) { Object value = bundle.get(key); String msg = String.format("%s %s (%s)", key, value.toString(), value.getClass().getName()); sb.append(msg).append("\n"); Log.d(TAG, msg);//from w ww .j a v a 2 s .co m } if (mDisplay != null) mDisplay.setText(sb.toString()); } else Log.e("Intent GCM ", "NO DATA IN INTENT"); }
From source file:bolts.MeasurementEvent.java
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) {/*from w w w. j a v a 2 s .c o m*/ Bundle logData = new Bundle(); ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager()); if (resolvedActivity != null) { logData.putString("class", resolvedActivity.getShortClassName()); } if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) { if (resolvedActivity != null) { logData.putString("package", resolvedActivity.getPackageName()); } if (applinkIntent.getData() != null) { logData.putString("outputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("outputURLScheme", applinkIntent.getScheme()); } } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) { if (applinkIntent.getData() != null) { logData.putString("inputURL", applinkIntent.getData().toString()); } if (applinkIntent.getScheme() != null) { logData.putString("inputURLScheme", applinkIntent.getScheme()); } } for (String key : appLinkData.keySet()) { Object o = appLinkData.get(key); if (o instanceof Bundle) { for (String subKey : ((Bundle) o).keySet()) { String logValue = objectToJSONString(((Bundle) o).get(subKey)); if (key.equals("referer_app_link")) { if (subKey.equalsIgnoreCase("url")) { logData.putString("refererURL", logValue); continue; } else if (subKey.equalsIgnoreCase("app_name")) { logData.putString("refererAppName", logValue); continue; } else if (subKey.equalsIgnoreCase("package")) { logData.putString("sourceApplication", logValue); continue; } } logData.putString(key + "/" + subKey, logValue); } } else { String logValue = objectToJSONString(o); if (key.equals("target_url")) { Uri targetURI = Uri.parse(logValue); logData.putString("targetURL", targetURI.toString()); logData.putString("targetURLHost", targetURI.getHost()); continue; } logData.putString(key, logValue); } } return logData; }
From source file:org.jboss.aerogear.android.authentication.impl.loader.support.SupportAuthenticationModuleAdapter.java
@Override public Loader<HeaderAndBody> onCreateLoader(int id, Bundle bundle) { SupportAuthenticationModuleAdapter.Methods method = (SupportAuthenticationModuleAdapter.Methods) bundle .get(METHOD);/*from ww w. j a va 2 s . com*/ Callback callback = (Callback) bundle.get(CALLBACK); Loader loader = null; switch (method) { case LOGIN: { Bundle loginBundle = bundle.getBundle(PARAMS); Map<String, String> loginParams = new HashMap<String, String>(loginBundle.size()); for (String key : loginBundle.keySet()) { loginParams.put(key, loginBundle.getString(key)); } loader = new SupportLoginLoader(applicationContext, callback, module, loginParams); } break; case LOGOUT: { loader = new SupportLogoutLoader(applicationContext, callback, module); } break; case ENROLL: { Map<String, String> params = (Map<String, String>) bundle.getSerializable(PARAMS); loader = new SupportEnrollLoader(applicationContext, callback, module, params); } break; } return loader; }
From source file:org.jboss.aerogear.android.authentication.impl.loader.AuthenticationModuleAdapter.java
@Override public Loader<HeaderAndBody> onCreateLoader(int id, Bundle bundle) { AuthenticationModuleAdapter.Methods method = (AuthenticationModuleAdapter.Methods) bundle.get(METHOD); Callback callback = (Callback) bundle.get(CALLBACK); Loader loader = null;//from w w w . j av a2s .co m switch (method) { case LOGIN: { Bundle loginBundle = bundle.getBundle(PARAMS); Map<String, String> loginParams = new HashMap<String, String>(loginBundle.size()); for (String key : loginBundle.keySet()) { loginParams.put(key, loginBundle.getString(key)); } loader = new LoginLoader(applicationContext, callback, module, loginParams); } break; case LOGOUT: { loader = new LogoutLoader(applicationContext, callback, module); } break; case ENROLL: { Map<String, String> params = (Map<String, String>) bundle.getSerializable(PARAMS); loader = new EnrollLoader(applicationContext, callback, module, params); } break; } return loader; }
From source file:com.example.etsmith.gcmupstream.MyGcmListenerService.java
@Override public void onMessageReceived(String from, final Bundle data) { super.onMessageReceived(from, data); Handler handler = new Handler(Looper.getMainLooper()); handler.post(new Runnable() { public void run() { Toast.makeText(getApplicationContext(), "Message Received: " + data.toString(), Toast.LENGTH_SHORT) .show();//from w ww.ja v a 2s . c om } }); for (String dataTag : data.keySet()) { if (!dataTag.equals(Constants.NOTIFICATION_BUNDLE)) { Log.d(TAG, dataTag + ": " + data.getString(dataTag)); } else { Bundle bundle = data.getBundle(dataTag); for (String bundleTag : bundle.keySet()) { Log.d(TAG, bundleTag + ": " + data.getString(bundleTag)); } } } String action = data.getString(Constants.ACTION); String status = data.getString(Constants.STATUS); if (Constants.REGISTER_NEW_CLIENT.equals(action) && Constants.STATUS_REGISTERED.equals(status)) { Log.d(TAG, "Registration Success"); } else if (Constants.UNREGISTER_CLIENT.equals(action) && Constants.STATUS_UNREGISTERED.equals(status)) { // token = ""; Log.d(TAG, "Unregistration Success"); } else if (from.startsWith(Constants.TOPIC_ROOT)) { Log.d(TAG, "Topic message: " + data.toString()); } else { Log.d(TAG, "Other type of action: " + data.toString()); } }
From source file:cn.bidaround.ytcore.kaixin.KaixinUtil.java
/** * ??http/*from w w w .j av a 2 s. c o m*/ * * @param context * * @param requestURL * ?? * @param httpMethod * GET POST * @param params * key-value??key???value???Stringbyte[] * @param photos * key-value??? keyfilename * value????InputStreambyte[] * ?InputStreamopenUrl? * @return ?JSON * @throws IOException */ public static String openUrl(Context context, String requestURL, String httpMethod, Bundle params, Map<String, Object> photos) throws IOException { OutputStream os; if (httpMethod.equals("GET")) { requestURL = requestURL + "?" + encodeUrl(params); } URL url = new URL(requestURL); HttpsURLConnection conn = (HttpsURLConnection) getConnection(context, url); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " KaixinAndroidSDK"); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestProperty("Connection", "close"); conn.setRequestProperty("Charsert", "UTF-8"); if (!httpMethod.equals("GET")) { Bundle dataparams = new Bundle(); // for (String key : params.keySet()) { // if (params.getByteArray(key) != null) { // dataparams.putByteArray(key, params.getByteArray(key)); // } // } String BOUNDARY = KaixinUtil.md5(String.valueOf(System.currentTimeMillis())); // ? String endLine = "\r\n"; conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + BOUNDARY + endLine).getBytes()); os.write((encodePostBody(params, BOUNDARY)).getBytes()); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; name=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } } if (photos != null && !photos.isEmpty()) { for (String key : photos.keySet()) { Object obj = photos.get(key); if (obj instanceof InputStream) { InputStream is = (InputStream) obj; try { os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes()); byte[] data = new byte[UPLOAD_BUFFER_SIZE]; int nReadLength = 0; while ((nReadLength = is.read(data)) != -1) { os.write(data, 0, nReadLength); } os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } finally { try { if (null != is) { is.close(); } } catch (Exception e) { Log.e(LOG_TAG, "Exception on closing input stream", e); } } } else if (obj instanceof byte[]) { byte[] byteArray = (byte[]) obj; os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine) .getBytes()); os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes()); os.write(byteArray); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } else { Log.e(LOG_TAG, "?"); } } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { response = read(conn.getErrorStream()); } return response; }
From source file:androidx.media.MediaUtils2.java
/** * Creates a {@link MediaMetadataCompat} from the {@link MediaMetadata2}. * * @param metadata2 A {@link MediaMetadata2} object. * @return The newly created {@link MediaMetadataCompat} object. */// ww w . j a va2 s. c o m MediaMetadataCompat createMediaMetadataCompat(MediaMetadata2 metadata2) { if (metadata2 == null) { return null; } MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); List<String> skippedKeys = new ArrayList<>(); Bundle bundle = metadata2.toBundle(); for (String key : bundle.keySet()) { Object value = bundle.get(key); if (value instanceof CharSequence) { builder.putText(key, (CharSequence) value); } else if (value instanceof Rating2) { builder.putRating(key, createRatingCompat((Rating2) value)); } else if (value instanceof Bitmap) { builder.putBitmap(key, (Bitmap) value); } else if (value instanceof Long) { builder.putLong(key, (Long) value); } else { // There is no 'float' or 'bundle' type in MediaMetadataCompat. skippedKeys.add(key); } } MediaMetadataCompat result = builder.build(); for (String key : skippedKeys) { Object value = bundle.get(key); if (value instanceof Float) { // Compatibility for MediaMetadata2.Builder.putFloat() result.getBundle().putFloat(key, (Float) value); } else if (METADATA_KEY_EXTRAS.equals(value)) { // Compatibility for MediaMetadata2.Builder.setExtras() result.getBundle().putBundle(key, (Bundle) value); } } return result; }