List of usage examples for android.os Bundle putString
public void putString(@Nullable String key, @Nullable String value)
From source file:Main.java
public static Bundle getContactFromNumber(String number, Context context) { ContentResolver cr = context.getContentResolver(); String[] projection = new String[] { Contacts._ID, Contacts.DISPLAY_NAME }; Bundle bundle = new Bundle(); Uri contactUri = Uri.withAppendedPath(Contacts.CONTENT_FILTER_URI, Uri.encode(number)); Cursor cursor = cr.query(contactUri, projection, null, null, null); try {/*from ww w.j a v a 2s .c o m*/ if (cursor.moveToFirst()) { for (String key : projection) { bundle.putString(key, cursor.getString(cursor.getColumnIndex(key))); } } return bundle; } catch (Exception e) { return null; } finally { cursor.close(); } }
From source file:com.mikecorrigan.bohrium.pubsub.JSONCodec.java
public static Bundle fromJson(JSONObject j) { Log.v(TAG, "fromJson"); try {//from ww w . ja va 2s . c o m Bundle bundle = new Bundle(); Iterator<String> i = j.keys(); while (i.hasNext()) { final String key = i.next(); final String value = j.getString(key); Log.v(TAG, "key=" + key + ", value=" + value); bundle.putString(key, value); } return bundle; } catch (JSONException e) { Log.e(TAG, "exception=" + e); Log.e(TAG, Log.getStackTraceString(e)); } return null; }
From source file:com.mdlive.myhealth.ProviderDetailsFragment.java
/** * Use this factory method to create a new instance of * this fragment./*from w w w . j ava 2s. c o m*/ * * @return A new instance of fragment MDLiveMyHealthProvidersFragment. */ public static ProviderDetailsFragment newInstance(String providerId) { Bundle args = new Bundle(); args.putString(PROVIDER_TAG, providerId); ProviderDetailsFragment fragment = new ProviderDetailsFragment(); fragment.setArguments(args); return fragment; }
From source file:eu.codeplumbers.cosi.wizards.firstrun.ConnectFragment.java
public static ConnectFragment create(String key) { Bundle args = new Bundle(); args.putString(ARG_KEY, key); ConnectFragment fragment = new ConnectFragment(); fragment.setArguments(args);/* w w w . j a va 2s. com*/ return fragment; }
From source file:org.openhab.habdroid.ui.OpenHABDiscoveryInboxFragment.java
public static OpenHABDiscoveryInboxFragment newInstance(String baseUrl, String username, String password) { OpenHABDiscoveryInboxFragment fragment = new OpenHABDiscoveryInboxFragment(); Bundle args = new Bundle(); args.putString(ARG_USERNAME, username); args.putString(ARG_PASSWORD, password); args.putString(ARG_BASEURL, baseUrl); fragment.setArguments(args);//from w w w . j av a2 s . co m return fragment; }
From source file:com.miz.mizuu.fragments.WebVideoFragment.java
public static WebVideoFragment newInstance(String type) { WebVideoFragment pageFragment = new WebVideoFragment(); Bundle bundle = new Bundle(); bundle.putString("type", type); pageFragment.setArguments(bundle);// w w w .j a v a 2 s .c o m return pageFragment; }
From source file:com.example.orangeweather.JSONWeatherParser.java
public static Bundle getWeather(JSONObject jObj) throws JSONException { Bundle bundle = new Bundle(); JSONObject coordObj = getObject("coord", jObj); bundle.putString(CityTags.CITY_NAME, getString("name", jObj)); bundle.putInt(CityTags.CITY_ID, getInt("id", jObj)); bundle.putInt(WeatherTags.WEATHER_DT, getInt("dt", jObj)); bundle.putString(CityTags.CITY_COORD, getDMSCoordinates(getFloat("lat", coordObj), getFloat("lon", coordObj))); JSONObject sysObj = getObject("sys", jObj); bundle.putString(CityTags.CITY_SYS_COUNTRY, getString("country", sysObj)); if (sysObj.has("sunrise")) { bundle.putInt(WeatherTags.WEATHER_SYS_SUNRISE, getInt("sunrise", sysObj)); }//from w w w. j a v a2s .com if (sysObj.has("sunset")) { bundle.putInt(WeatherTags.WEATHER_SYS_SUNSET, getInt("sunset", sysObj)); } JSONArray jArr = jObj.getJSONArray("weather"); JSONObject JSONWeather = jArr.getJSONObject(0); bundle.putString(WeatherTags.WEATHER_CONDITION_DESC, getString("description", JSONWeather)); bundle.putString(WeatherTags.WEATHER_CONDITION_MAIN, getString("main", JSONWeather)); JSONObject mainObj = getObject("main", jObj); bundle.putInt(WeatherTags.WEATHER_MAIN_HUMIDITY, getInt("humidity", mainObj)); bundle.putInt(WeatherTags.WEATHER_MAIN_PRESSURE, getInt("pressure", mainObj)); bundle.putString(WeatherTags.WEATHER_MAIN_TEMP_MAX, getTemperatureString(getFloat("temp_max", mainObj))); bundle.putString(WeatherTags.WEATHER_MAIN_TEMP_MIN, getTemperatureString(getFloat("temp_min", mainObj))); bundle.putString(WeatherTags.WEATHER_MAIN_TEMP, getTemperatureString(getFloat("temp", mainObj))); JSONObject wObj = getObject("wind", jObj); bundle.putFloat(WeatherTags.WEATHER_WIND_SPEED, getFloat("speed", wObj)); bundle.putInt(WeatherTags.WEATHER_WIND_DEG, getInt("deg", wObj)); if (wObj.has("var_beg")) { bundle.putInt(WeatherTags.WEATHER_WIND_VAR_BEG, getInt("var_beg", wObj)); } if (wObj.has("var_end")) { bundle.putInt(WeatherTags.WEATHER_WIND_VAR_END, getInt("var_end", wObj)); } JSONObject cObj = getObject("clouds", jObj); bundle.putInt(WeatherTags.WEATHER_CLOUDS_ALL, getInt("all", cObj)); return bundle; }
From source file:edu.mit.mobile.android.locast.sync.LocastSyncService.java
/** * Convenience method to request a sync. * * This wraps {@link ContentResolver#requestSync(Account, String, Bundle)} * and fills in the necessary extras./*w w w . ja v a 2s.c o m*/ * * @param account * @param what the uri of the item that needs to be sync'd. can be null * @param explicitSync * if true, adds {@link ContentResolver#SYNC_EXTRAS_MANUAL} to * the extras * @param extras */ public static void startSync(Account account, Uri what, Bundle extras) { if (what != null) { extras.putString(LocastSyncService.EXTRA_SYNC_URI, what.toString()); } if (extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false)) { if (SYNC_ADAPTER != null) { if (DEBUG) { Log.d(TAG, "canceling current sync to make room for expedited sync of " + what); } // only cancel the ongoing sync, to leave the queue untouched. SYNC_ADAPTER.cancelCurrentSync(); } } if (DEBUG) { Log.d(TAG, "requesting sync for " + account + " with extras: " + extras); } ContentResolver.requestSync(account, MediaProvider.AUTHORITY, extras); }
From source file:com.facebook.LegacyTokenCacheTest.java
private static void putString(String key, Bundle bundle) { bundle.putString(key, new String(getCharArray())); }
From source file:com.miz.mizuu.fragments.RelatedMoviesFragment.java
public static RelatedMoviesFragment newInstance(String tmdbId, boolean setBackground) { RelatedMoviesFragment pageFragment = new RelatedMoviesFragment(); Bundle bundle = new Bundle(); bundle.putString("tmdbId", tmdbId); bundle.putBoolean("setBackground", setBackground); pageFragment.setArguments(bundle);/*from w ww. ja v a 2s .c o m*/ return pageFragment; }