List of usage examples for android.os Bundle putString
public void putString(@Nullable String key, @Nullable String value)
From source file:Main.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP_MR1) public static Bundle persistableBundleToBundle(PersistableBundle persistableBundle) { Set<String> keySet = persistableBundle.keySet(); Bundle bundle = new Bundle(); for (String key : keySet) { Object value = persistableBundle.get(key); if (value instanceof Boolean) { bundle.putBoolean(key, (boolean) value); } else if (value instanceof Integer) { bundle.putInt(key, (int) value); } else if (value instanceof String) { bundle.putString(key, (String) value); } else if (value instanceof String[]) { bundle.putStringArray(key, (String[]) value); } else if (value instanceof PersistableBundle) { Bundle innerBundle = persistableBundleToBundle((PersistableBundle) value); bundle.putBundle(key, innerBundle); }//from w w w. jav a 2 s.c o m } return bundle; }
From source file:Main.java
public static Bundle decodeUrl(String s) { Bundle params = new Bundle(); if (s != null) { String[] array = s.split("&"); String[] arr$ = array;/* w w w . j a va 2s. c om*/ int len$ = array.length; for (int i$ = 0; i$ < len$; ++i$) { String parameter = arr$[i$]; String[] v = parameter.split("="); if (v.length >= 2 && v[1] != null) { params.putString(URLDecoder.decode(v[0]), URLDecoder.decode(v[1])); } else { params.putString(URLDecoder.decode(v[0]), ""); } } } return params; }
From source file:bolts.MeasurementEvent.java
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) {/* w ww . j a v a 2 s.co 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:com.mb.android.playbackmediator.utils.Utils.java
/** * Builds and returns a {@link android.os.Bundle} which contains a select subset of data in the * {@link MediaInfo}. Since {@link MediaInfo} is not {@link android.os.Parcelable}, one can use this * container bundle to pass around from one activity to another. * * @param info/*www. jav a2 s. c o m*/ * @return * @see <code>toMediaInfo()</code> */ public static Bundle fromMediaInfo(MediaInfo info) { if (null == info) { return null; } MediaMetadata md = info.getMetadata(); Bundle wrapper = new Bundle(); wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE)); wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE)); wrapper.putString(KEY_URL, info.getContentId()); wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO)); wrapper.putString(KEY_CONTENT_TYPE, info.getContentType()); wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType()); wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration()); if (!md.getImages().isEmpty()) { ArrayList<String> urls = new ArrayList<String>(); for (WebImage img : md.getImages()) { urls.add(img.getUrl().toString()); } wrapper.putStringArrayList(KEY_IMAGES, urls); } JSONObject customData = info.getCustomData(); if (null != customData) { wrapper.putString(KEY_CUSTOM_DATA, customData.toString()); } return wrapper; }
From source file:au.id.micolous.frogjump.Util.java
public static void sendGcmMessage(String action, @Nullable Bundle message_p) { final long message_id = rng.nextLong(); final Bundle message; if (message_p == null) { message = new Bundle(); } else {//from www . j ava2 s .co m message = new Bundle(message_p); } message.putString("a", action); message.putString("v", Integer.toString(getVersionCode())); FrogjumpApplication app = FrogjumpApplication.getInstance(); final GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(app); final String gcm_to = app.getString(R.string.gcm_defaultSenderId) + "@gcm.googleapis.com"; (new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { try { gcm.send(gcm_to, Long.toString(message_id), message); return true; } catch (IOException ex) { Log.e(TAG, "sendGcmMessage fail", ex); return false; } } }).execute(); }
From source file:com.ntsync.android.sync.activities.CreatePwdProgressDialog.java
/** * Creates a new Key// w ww. j av a2s. c o m * * @param userName * @param pwdSalt * @param authtoken * @return invisible Dialog */ public static CreatePwdProgressDialog newInstance(String userName, byte[] currPwdSalt) { CreatePwdProgressDialog dlg = new CreatePwdProgressDialog(); Bundle args = new Bundle(); args.putString(KeyPasswordActivity.PARAM_USERNAME, userName); args.putByteArray(KeyPasswordActivity.PARAM_SALT, currPwdSalt); dlg.setArguments(args); return dlg; }
From source file:com.google.android.libraries.cast.companionlibrary.utils.Utils.java
/** * Builds and returns a {@link Bundle} which contains a select subset of data in the * {@link MediaInfo}. Since {@link MediaInfo} is not {@link Parcelable}, one can use this * container bundle to pass around from one activity to another. * * @see <code>bundleToMediaInfo()</code> *//*from w w w. j a v a 2 s.c o m*/ public static Bundle mediaInfoToBundle(MediaInfo info) { if (info == null) { return null; } MediaMetadata md = info.getMetadata(); Bundle wrapper = new Bundle(); wrapper.putString(MediaMetadata.KEY_TITLE, md.getString(MediaMetadata.KEY_TITLE)); wrapper.putString(MediaMetadata.KEY_SUBTITLE, md.getString(MediaMetadata.KEY_SUBTITLE)); wrapper.putString(KEY_URL, info.getContentId()); wrapper.putString(MediaMetadata.KEY_STUDIO, md.getString(MediaMetadata.KEY_STUDIO)); wrapper.putString(KEY_CONTENT_TYPE, info.getContentType()); wrapper.putInt(KEY_STREAM_TYPE, info.getStreamType()); wrapper.putLong(KEY_STREAM_DURATION, info.getStreamDuration()); if (!md.getImages().isEmpty()) { ArrayList<String> urls = new ArrayList<>(); for (WebImage img : md.getImages()) { urls.add(img.getUrl().toString()); } wrapper.putStringArrayList(KEY_IMAGES, urls); } JSONObject customData = info.getCustomData(); if (customData != null) { wrapper.putString(KEY_CUSTOM_DATA, customData.toString()); } if (info.getMediaTracks() != null && !info.getMediaTracks().isEmpty()) { try { JSONArray jsonArray = new JSONArray(); for (MediaTrack mt : info.getMediaTracks()) { JSONObject jsonObject = new JSONObject(); jsonObject.put(KEY_TRACK_NAME, mt.getName()); jsonObject.put(KEY_TRACK_CONTENT_ID, mt.getContentId()); jsonObject.put(KEY_TRACK_ID, mt.getId()); jsonObject.put(KEY_TRACK_LANGUAGE, mt.getLanguage()); jsonObject.put(KEY_TRACK_TYPE, mt.getType()); if (mt.getSubtype() != MediaTrack.SUBTYPE_UNKNOWN) { jsonObject.put(KEY_TRACK_SUBTYPE, mt.getSubtype()); } if (mt.getCustomData() != null) { jsonObject.put(KEY_TRACK_CUSTOM_DATA, mt.getCustomData().toString()); } jsonArray.put(jsonObject); } wrapper.putString(KEY_TRACKS_DATA, jsonArray.toString()); } catch (JSONException e) { LOGE(TAG, "mediaInfoToBundle(): Failed to convert Tracks data to json", e); } } return wrapper; }
From source file:de.geeksfactory.opacclient.OpacClient.java
public static Bundle mapToBundle(Map<String, String> map) { if (map == null) { return null; }/*from w w w . j a v a2s . c o m*/ Bundle b = new Bundle(); for (Entry<String, String> e : map.entrySet()) { b.putString(e.getKey(), e.getValue()); } return b; }
From source file:com.ruesga.rview.fragments.SnippetFragment.java
public static SnippetFragment newInstance(Context context, Uri snippet, String mimeType) { SnippetFragment fragment = new SnippetFragment(); Bundle arguments = new Bundle(); if (snippet != null) { arguments.putParcelable(EXTRA_SNIPPET_URI, snippet); arguments.putString(EXTRA_SNIPPET_MIMETYPE, mimeType); } else {//from w ww . j a va 2 s . co m try { Uri uri = CacheHelper.createNewTemporaryFileUri(context, ".snippet"); arguments.putParcelable(EXTRA_TEMP_SNIPPET_URI, uri); } catch (IOException ex) { Log.e(TAG, "Can't create temporary snippet", ex); } } fragment.setArguments(arguments); return fragment; }
From source file:com.ntsync.android.sync.activities.CreatePwdProgressDialog.java
/** * Recreates a Key based on a existing Password * /* w ww. j av a 2 s . c o m*/ * @param userName * @param pwdSalt * @param authtoken * @return invisible Dialog */ public static CreatePwdProgressDialog newInstance(String userName, String pwd, byte[] currPwdSalt, byte[] pwdCheck) { CreatePwdProgressDialog dlg = new CreatePwdProgressDialog(); Bundle args = new Bundle(); args.putString(KeyPasswordActivity.PARAM_USERNAME, userName); args.putString(PARAM_PWD, pwd); args.putByteArray(KeyPasswordActivity.PARAM_SALT, currPwdSalt); args.putByteArray(KeyPasswordActivity.PARAM_CHECK, pwdCheck); if (pwd == null) { throw new IllegalArgumentException("pwd is null"); } dlg.setArguments(args); return dlg; }