List of usage examples for android.os Bundle putString
public void putString(@Nullable String key, @Nullable String value)
From source file:com.trk.aboutme.facebook.internal.Utility.java
public static boolean queryAppAttributionSupportAndWait(final String applicationId) { synchronized (LOCK) { // Cache the last app checked results. if (applicationId.equals(lastAppCheckedForAttributionStatus)) { return attributionAllowedForLastAppChecked; }/*from w ww . j a va 2 s . c om*/ Bundle supportsAttributionParams = new Bundle(); supportsAttributionParams.putString(APPLICATION_FIELDS, SUPPORTS_ATTRIBUTION); Request pingRequest = Request.newGraphPathRequest(null, applicationId, null); pingRequest.setParameters(supportsAttributionParams); GraphObject supportResponse = pingRequest.executeAndWait().getGraphObject(); Object doesSupportAttribution = false; if (supportResponse != null) { doesSupportAttribution = supportResponse.getProperty(SUPPORTS_ATTRIBUTION); } if (!(doesSupportAttribution instanceof Boolean)) { // Should never happen, but be safe in case server returns non-Boolean doesSupportAttribution = false; } lastAppCheckedForAttributionStatus = applicationId; attributionAllowedForLastAppChecked = ((Boolean) doesSupportAttribution == true); return attributionAllowedForLastAppChecked; } }
From source file:com.spoiledmilk.ibikecph.util.HttpUtils.java
public static Message JSONtoUserDataMessage(JsonNode result, UserData userData) { Message ret = new Message(); Bundle data = new Bundle(); if (result != null) { data.putBoolean("success", result.get("success").asBoolean()); data.putString("info", result.get("info").asText()); JsonNode dataNode = result.get("data"); if (dataNode != null) { data.putInt("id", dataNode.get("id").asInt()); data.putString("name", dataNode.get("name").asText()); data.putString("email", dataNode.get("email").asText()); if (dataNode.has("image_url")) data.putString("image_url", dataNode.get("image_url").asText()); }/*from w w w . j a va 2 s.com*/ ret.setData(data); } return ret; }
From source file:com.spoiledmilk.ibikecph.util.HttpUtils.java
public static Message JSONtoMessage(JsonNode result) { Message ret = new Message(); Bundle data = new Bundle(); if (result != null) { data.putBoolean("success", result.get("success").asBoolean()); data.putString("info", result.get("info").asText()); if (result.has("errors")) data.putString("errors", result.get("errors").asText()); 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()); }/* ww w . j av a2 s.co m*/ } ret.setData(data); return ret; }
From source file:net.reichholf.dreamdroid.helpers.enigma2.Timer.java
/** * @param mph - A MultiPaneHandler instance * @param timer - A timer (ExtendedHashMap) * @param target - The target fragment (after saving/cancellation) * @param create - set to true if a new timer should be created instead of editing an existing one */// w w w . j a v a2 s. com public static void edit(MultiPaneHandler mph, ExtendedHashMap timer, Fragment target, boolean create) { ExtendedHashMap data = new ExtendedHashMap(); TimerEditFragment f = new TimerEditFragment(); Bundle args = new Bundle(); data.put("timer", timer); args.putSerializable(DATA, data); String action = create ? DreamDroid.ACTION_CREATE : Intent.ACTION_EDIT; args.putString("action", action); f.setArguments(args); if (target != null) { f.setTargetFragment(target, Statics.REQUEST_EDIT_TIMER); } mph.showDetails(f, true); }
From source file:Main.java
public static Bundle hashtableToBundle(Hashtable table) { Bundle bundle = new Bundle(); Iterator iterator = table.keySet().iterator(); String key;//from w w w .jav a 2s . com Object val; while (iterator.hasNext()) { key = (String) iterator.next(); val = table.get(key); if (val instanceof Integer) { bundle.putInt(key, (Integer) val); } else if (val instanceof String) { bundle.putString(key, (String) val); } } return bundle; }
From source file:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void create(final MapBase map, String layerName, String layerUrl, int tmsType) { String sErr = map.getContext().getString(R.string.error_occurred); try {//from www .j av a 2 s . c o m File outputPath = map.cretateLayerStorage(); //create layer description file JSONObject oJSONRoot = new JSONObject(); oJSONRoot.put(JSON_NAME_KEY, layerName); oJSONRoot.put(JSON_URL_KEY, layerUrl); oJSONRoot.put(JSON_VISIBILITY_KEY, true); oJSONRoot.put(JSON_TYPE_KEY, LAYERTYPE_TMS); oJSONRoot.put(JSON_TMSTYPE_KEY, tmsType); //send message to handler to show error or add new layer File file = new File(outputPath, LAYER_CONFIG); FileUtil.createDir(outputPath); FileUtil.writeToFile(file, oJSONRoot.toString()); if (map.getMapEventsHandler() != null) { Bundle bundle = new Bundle(); bundle.putBoolean(BUNDLE_HASERROR_KEY, false); bundle.putString(BUNDLE_MSG_KEY, map.getContext().getString(R.string.message_layer_added)); bundle.putInt(BUNDLE_TYPE_KEY, MSGTYPE_LAYER_ADDED); bundle.putSerializable(BUNDLE_PATH_KEY, outputPath); Message msg = new Message(); msg.setData(bundle); map.getMapEventsHandler().sendMessage(msg); } return; } catch (FileNotFoundException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } catch (JSONException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } catch (IOException e) { Log.d(TAG, "Exception: " + e.getLocalizedMessage()); sErr += ": " + e.getLocalizedMessage(); } //if we here something wrong occurred Toast.makeText(map.getContext(), sErr, Toast.LENGTH_SHORT).show(); }
From source file:com.aleiacampo.oristanobus.util.ViewUtil.java
public static void loadMostSearched(final AppCompatActivity appCompatActivity) { final ArrayList<Stop> stopsList = new ArrayList<>(); final ArrayList<String> stopsNameList = new ArrayList<>(); new AsyncTask<Void, Void, Void>() { @Override//from w w w. ja v a 2 s. c om protected void onPreExecute() { super.onPreExecute(); if (!ConnectionsHandler.isNetworkPresent(appCompatActivity)) { this.cancel(true); stopsNameList.add("Connessione dati non presente"); ListView listView_searched = (ListView) appCompatActivity .findViewById(R.id.textView_mostSerched); ArrayAdapter<String> adapter = new ArrayAdapter<>(appCompatActivity.getApplicationContext(), R.layout.text_view, stopsNameList); listView_searched.setAdapter(adapter); } } @Override protected Void doInBackground(Void... params) { Stop stop; String url = "http://www.aleiacampo.com/stops.php?clicked=10"; WebServerHandler webServerHandler = new WebServerHandler(); String jsonStr = webServerHandler.getJSONData(url); try { JSONObject jsonObject = new JSONObject(jsonStr); JSONArray stopsJSON = jsonObject.getJSONArray("bus_stops"); for (int i = 0; i < stopsJSON.length(); i++) { JSONObject bus_stop = stopsJSON.getJSONObject(i); stop = new Stop(bus_stop.getInt("id_line"), bus_stop.getInt("id_stop"), bus_stop.getString("name_line"), bus_stop.getString("name_stop")); stopsList.add(stop); } } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); for (Stop stop : stopsList) { stopsNameList.add("Linea " + stop.idLine + " - " + stop.nameStop); } ListView listView_searched = (ListView) appCompatActivity.findViewById(R.id.textView_mostSerched); ArrayAdapter<String> adapter = new ArrayAdapter<>(appCompatActivity.getApplicationContext(), R.layout.text_view, stopsNameList); listView_searched.setAdapter(adapter); listView_searched.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Bundle bundle = new Bundle(); bundle.putInt("id_stop", stopsList.get(position).idStop); bundle.putInt("id_line", stopsList.get(position).idLine); bundle.putString("name_line", stopsList.get(position).nameLine); bundle.putString("name_stop", stopsList.get(position).nameStop); FragmentManager fragmentManager = appCompatActivity.getSupportFragmentManager(); TimesFragment timesFragment = new TimesFragment(); timesFragment.setArguments(bundle); appCompatActivity.onBackPressed(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.home_frag, timesFragment, "Times"); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); } }.execute(); }
From source file:Main.java
/** * Decode parameters contained in the provided String and generate a {@link Bundle} associating * parameters name and values.//from ww w . j av a2 s.c om * * @param url * Url that we decode parameters from. * @return Bundle containing decoded parameters. */ public static Bundle decodeUrl(String url) { Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(url) && url.indexOf("?") != -1) { String urlParameters = url.substring(url.indexOf("?") + 1); String[] parameters = urlParameters.split("&"); for (String parameter : parameters) { String[] keyValue = parameter.split("="); if (keyValue.length == 2) { bundle.putString(URLDecoder.decode(keyValue[0]), URLDecoder.decode(keyValue[1])); } } } return bundle; }
From source file:com.ferasinfotech.gwreader.ScreenSlidePageFragment.java
/** * Alternate Factory method for this fragment class. Constructs a new fragment for the given page number, * with page title given as a string parameter without a JSON object containing details. * (used to construct and empty page when a JSON parsing error of a story occurs) *//*w ww .jav a 2s. co m*/ public static ScreenSlidePageFragment create(int pageNumber, int numPages, String story_title) { ScreenSlidePageFragment fragment = new ScreenSlidePageFragment(); Bundle args = new Bundle(); args.putInt(ARG_PAGE, pageNumber); args.putInt(ARG_STORY_ID, 0); args.putString(ARG_TITLE, story_title + " (" + (pageNumber + 1) + "/" + numPages + ")"); args.putString(ARG_SUMMARY, ""); args.putString(ARG_HEADLINE, ""); args.putString(ARG_COVER_PHOTO, ""); args.putString(ARG_STORY_STRING, ""); fragment.setArguments(args); return fragment; }
From source file:com.zotfeed2.CardContentFragment.java
public static CardContentFragment newInstance(String request) { CardContentFragment fragment = new CardContentFragment(); Bundle bundle = new Bundle(); bundle.putString(COMMAND, request); fragment.setArguments(bundle);// ww w .j a v a 2 s . co m return fragment; }