List of usage examples for android.os Bundle putString
public void putString(@Nullable String key, @Nullable String value)
From source file:com.frostwire.android.gui.dialogs.HandpickedTorrentDownloadDialog.java
public static HandpickedTorrentDownloadDialog newInstance(Context ctx, TorrentInfo tinfo, String magnetUri, long torrentFetcherDownloadTokenId) { ////from w w w. j ava 2 s . co m // ideas: - pre-selected file(s) to just check the one(s) // - passing a file path // - passing a byte[] to create the tinfo from. final HandpickedTorrentDownloadDialog dlg = new HandpickedTorrentDownloadDialog(); // this creates a bundle that gets passed to setArguments(). It's supposed to be ready // before the dialog is attached to the underlying activity, after we attach to it, then // we are able to use such Bundle to create our adapter. final TorrentFileEntryList torrentInfoList = getTorrentInfoList(tinfo.files()); boolean[] allChecked = new boolean[torrentInfoList.list.size()]; for (int i = 0; i < allChecked.length; i++) { allChecked[i] = true; } dlg.prepareArguments(R.drawable.download_icon, tinfo.name(), ctx.getString(R.string.pick_the_files_you_want_to_download_from_this_torrent), JsonUtils.toJson(torrentInfoList), SelectionMode.MULTIPLE_SELECTION); final Bundle arguments = dlg.getArguments(); arguments.putByteArray(BUNDLE_KEY_TORRENT_INFO_DATA, tinfo.bencode()); arguments.putString(BUNDLE_KEY_MAGNET_URI, magnetUri); arguments.putLong(BUNDLE_KEY_TORRENT_FETCHER_DOWNLOAD_TOKEN_ID, torrentFetcherDownloadTokenId); arguments.putBooleanArray(BUNDLE_KEY_CHECKED_OFFSETS, allChecked); return dlg; }
From source file:com.google.sample.castcompanionlibrary.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. * * @param info//from w ww .j a v a 2s . 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()); } 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()); jsonObject.put(KEY_TRACK_SUBTYPE, mt.getSubtype()); if (null != mt.getCustomData()) { jsonObject.put(KEY_TRACK_CUSTOM_DATA, mt.getCustomData().toString()); } jsonArray.put(jsonObject); } wrapper.putString(KEY_TRACKS_DATA, jsonArray.toString()); } catch (JSONException e) { LOGE(TAG, "fromMediaInfo(): Failed to convert Tracks data to json", e); } } return wrapper; }
From source file:dk.kk.ibikecphlib.util.HttpUtils.java
public static Message JSONtoMessage(JsonNode result) { Message ret = new Message(); Bundle data = new Bundle(); if (result != null) { if (result.has("success")) data.putBoolean("success", result.get("success").asBoolean()); if (result.has("info")) data.putString("info", result.get("info").asText()); if (result.has("has_password")) data.putBoolean("has_password", result.get("has_password").asBoolean()); if (result.has("invalid_token")) { if (result.get("invalid_token").asBoolean()) { data.putBoolean("invalid_token", result.get("invalid_token").asBoolean()); IBikeApplication.logoutWrongToken(); }/* ww w .ja v a 2s . co m*/ } /*if (result.has("errors")) data.putString("errors", result.get("errors").get(0).asText());*/ } if (result != null && result.has("data")) { JsonNode dataNode = result.get("data"); if (dataNode != null) { if (dataNode.has("id")) data.putInt("id", dataNode.get("id").asInt()); if (dataNode.has("auth_token")) data.putString("auth_token", dataNode.get("auth_token").asText()); if (dataNode.has("signature")) data.putString("signature", dataNode.get("signature").asText()); if (dataNode.has("provider")) data.putString("provider", dataNode.get("provider").asText()); /*if (dataNode.has("errors")) data.putString("errors", dataNode.get("errors").get(0).asText());*/ } } ret.setData(data); return ret; }
From source file:com.cm.android.beercellar.ui.ImageDetailFragment.java
/** * Factory method to generate a new instance of the fragment given an image number. * * @param imageUrl The image url to load * @return A new instance of ImageDetailFragment with imageNum extras *//*from ww w . j a v a 2 s .c o m*/ public static ImageDetailFragment newInstance(String imageUrl, String imageThumbnailUrl) { final ImageDetailFragment f = new ImageDetailFragment(); final Bundle args = new Bundle(); args.putString(IMAGE_DATA_EXTRA, imageUrl); args.putString(IMAGE_THUMBNAIL_DATA_EXTRA, imageThumbnailUrl); f.setArguments(args); return f; }
From source file:com.rubika.aotalk.aou.FragmentGuides.java
public static FragmentGuides newInstance(AOU a, String search) { FragmentGuides f = new FragmentGuides(); Bundle args = new Bundle(); args.putString("search", search); f.setArguments(args);/* ww w .j a v a2 s . co m*/ aou = a; return f; }
From source file:com.fsck.k9.helper.Utility.java
/** * Assign the contact to the badge.//from w w w .j a v a 2s . c om * * On 4.3, we pass the address name as extra info so that if the contact doesn't exist * the name is auto-populated. * * @param contactBadge the badge to the set the contact for * @param address the address to look for a contact for. */ public static void setContactForBadge(ContactBadge contactBadge, Address address) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { Bundle extraContactInfo = new Bundle(); extraContactInfo.putString(ContactsContract.Intents.Insert.NAME, address.getPersonal()); contactBadge.assignContactFromEmail(address.getAddress(), true, extraContactInfo); } else { contactBadge.assignContactFromEmail(address.getAddress(), true); } }
From source file:Main.java
/** * Connect to an HTTP URL and return the response as a string. * //from w w w . j ava 2 s.c o 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 { if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { // use method override params.putString("method", method); conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.getOutputStream().write(encodeUrl(params).getBytes("UTF-8")); } 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.userhook.UserHook.java
public static void showFeedback() { Intent intent = new Intent(activityLifecycle.getCurrentActivity(), UHHostedPageActivity.class); intent.putExtra(UHHostedPageActivity.TYPE_FEEDBACK, feedbackScreenTitle); if (feedbackCustomFields != null && feedbackCustomFields.size() > 0) { Bundle bundle = new Bundle(); for (String key : feedbackCustomFields.keySet()) { bundle.putString(key, feedbackCustomFields.get(key)); }//from ww w . j av a2 s. c o m intent.putExtra(UH_CUSTOM_FIELDS, bundle); } activityLifecycle.getCurrentActivity().startActivity(intent); }
From source file:com.marpies.ane.facebook.accountkit.utils.FREObjectUtils.java
public static Bundle getBundle(FREArray array) { Bundle result = null; try {/* ww w . j av a 2s. c om*/ long length = array.getLength(); if (length > 0) { result = new Bundle(); for (long i = 0; i < length;) { String key = getString(array.getObjectAt(i++)); String value = getString(array.getObjectAt(i++)); result.putString(key, value); } } } catch (FREInvalidObjectException e) { e.printStackTrace(); } catch (FREWrongThreadException e) { e.printStackTrace(); } return result; }
From source file:com.chess.genesis.data.GameParser.java
public static Bundle parse(final JSONObject data) { final Bundle game = new Bundle(); try {//from w w w.jav a 2s.co m game.putInt("gametype", Enums.GameType(data.optString("gametype", "genesis"))); } catch (final RuntimeException e) { game.putInt("gametype", Enums.GENESIS_CHESS); } try { game.putInt("opponent", Enums.OpponentType(data.optString("opponent", "human"))); } catch (final RuntimeException e) { game.putInt("opponent", Enums.HUMAN_OPPONENT); } game.putString("name", data.optString("name", "untitled")); game.putLong("ctime", data.optLong("ctime", System.currentTimeMillis())); game.putLong("stime", data.optLong("stime", System.currentTimeMillis())); final GamePosition pos = parsePosition(data.optString("history", " "), game.getInt("gametype")); game.putString("history", pos.history); game.putString("zfen", pos.zfen); return game; }