List of usage examples for android.os Bundle Bundle
public Bundle()
From source file:ServiceConsumerActivity.java
public void queryService() { if (isBound) { Bundle bundle = new Bundle(); bundle.putString("location", editText.getText().toString().trim()); Message message = Message.obtain(); message.replyTo = messengerFromService; message.setData(bundle);/*from ww w. ja v a2 s . co m*/ try { messengerToService.send(message); } catch (RemoteException e) { e.printStackTrace(); } } else { textView.setText(R.string.report_appears_here); doToast(R.string.service_not_bound); } }
From source file:fr.simon.marquis.preferencesmanager.ui.RestoreDialogFragment.java
private static RestoreDialogFragment newInstance(String fullPath, List<String> backups) { RestoreDialogFragment dialog = new RestoreDialogFragment(); Bundle args = new Bundle(); JSONArray array = new JSONArray(backups); args.putString(ARG_FULL_PATH, fullPath); args.putString(ARG_BACKUPS, array.toString()); dialog.setArguments(args);// w w w.j a v a 2 s . co m return dialog; }
From source file:fr.cph.chicago.fragment.BusFragment.java
/** * Returns a new instance of this fragment for the given section number. * /*from ww w . jav a 2 s . c o m*/ * @param sectionNumber * the section number * @return the fragment */ public static BusFragment newInstance(final int sectionNumber) { BusFragment fragment = new BusFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; }
From source file:br.liveo.ndrawer.ui.fragment.MainFragment12.java
public static MainFragment12 newInstance(String text) { MainFragment12 mFragment = new MainFragment12(); Bundle mBundle = new Bundle(); mBundle.putString(TEXT_FRAGMENT, text); mFragment.setArguments(mBundle);/*from ww w.j av a2 s . com*/ return mFragment; }
From source file:Main.java
/** * Create a Parcelable Bundle containing 3 parameters: String, int, int for transport from the test package engine.<br> * It will be used by {@link Message#setData(Bundle)} for sending a part of whole message from engine.<br> * The String message is stored via Bundle.putCharArray using {@link #BUNDLE_SMALL_PARCEL_ID} as the key for the item.<br> * The int message is stored via Bundle.putCharArray using {@link #BUNDLE_SMALL_PARCEL_INDEX} as the key for the item.<br> * The int message is stored via Bundle.putCharArray using {@link #BUNDLE_SMALL_PARCEL_TOTALNUMBER} as the key for the item.<br> * //from w w w . j av a 2s.c o m * @param ID String, the message's ID. * @param index int, the index of this parcel of the whole message. * @param totalNumber int, indicate the total number of parcels will be sent for a whole message.. * @return Parcelable Bundle * @see Bundle#putCharArray(String, char[]) * @see Bundle#getCharArray(String) * @see #getParcelableIDFromSmallParcel(Parcelable) * @see #getParcelableIndexFromSmallParcel(Parcelable) * @see #getParcelableTotalNumberFromSmallParcel(Parcelable) * @see #isSmallParcelOfWholeMessage(Bundle) */ public static Bundle setBundleOfSmallParcel(String ID, int index, int totalNumber) { Bundle bundle = new Bundle(); bundle.putString(BUNDLE_SMALL_PARCEL_ID, ID); bundle.putInt(BUNDLE_SMALL_PARCEL_INDEX, index); bundle.putInt(BUNDLE_SMALL_PARCEL_TOTALNUMBER, totalNumber); bundle.setClassLoader(Bundle.class.getClassLoader()); return bundle; }
From source file:com.mifos.mifosxdroid.online.ClientChargeFragment.java
public static ClientChargeFragment newInstance(int clientId, List<Charges> chargesList) { ClientChargeFragment fragment = new ClientChargeFragment(); Bundle args = new Bundle(); args.putInt(Constants.CLIENT_ID, clientId); fragment.setArguments(args);/*from w w w . j av a2 s . c o m*/ if (chargesList != null) fragment.setChargesList(chargesList); return fragment; }
From source file:com.scrachx.foodfacts.checker.ui.history.HistoryFragment.java
public static HistoryFragment newInstance() { Bundle args = new Bundle(); HistoryFragment fragment = new HistoryFragment(); fragment.setArguments(args);/*from w w w. ja v a 2s .c o m*/ return fragment; }
From source file:org.openhab.habdroid.ui.OpenHABBindingFragment.java
public static OpenHABBindingFragment newInstance(String baseUrl, String username, String password) { OpenHABBindingFragment fragment = new OpenHABBindingFragment(); Bundle args = new Bundle(); args.putString(ARG_USERNAME, username); args.putString(ARG_PASSWORD, password); args.putString(ARG_BASEURL, baseUrl); fragment.setArguments(args);/* w ww . ja va 2 s.c o m*/ return fragment; }
From source file:io.v.android.apps.syncslides.DeckChooserFragment.java
/** * Returns a new instance of this fragment for the given section number. */// w w w .j av a 2 s . c om public static DeckChooserFragment newInstance(int sectionNumber) { DeckChooserFragment fragment = new DeckChooserFragment(); Bundle args = new Bundle(); args.putInt(ARG_SECTION_NUMBER, sectionNumber); fragment.setArguments(args); return fragment; }
From source file:com.facebook.internal.BundleJSONConverterTests.java
@SmallTest public void testSimpleValues() throws JSONException { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1st"); arrayList.add("2nd"); arrayList.add("third"); Bundle innerBundle1 = new Bundle(); innerBundle1.putInt("inner", 1); Bundle innerBundle2 = new Bundle(); innerBundle2.putString("inner", "2"); innerBundle2.putStringArray("deep list", new String[] { "7", "8" }); innerBundle1.putBundle("nested bundle", innerBundle2); Bundle b = new Bundle(); b.putBoolean("boolValue", true); b.putInt("intValue", 7); b.putLong("longValue", 5000000000l); b.putDouble("doubleValue", 3.14); b.putString("stringValue", "hello world"); b.putStringArray("stringArrayValue", new String[] { "first", "second" }); b.putStringArrayList("stringArrayListValue", arrayList); b.putBundle("nested", innerBundle1); JSONObject json = BundleJSONConverter.convertToJSON(b); assertNotNull(json);/*from ww w . j a v a 2s . c o m*/ assertEquals(true, json.getBoolean("boolValue")); assertEquals(7, json.getInt("intValue")); assertEquals(5000000000l, json.getLong("longValue")); assertEquals(3.14, json.getDouble("doubleValue")); assertEquals("hello world", json.getString("stringValue")); JSONArray jsonArray = json.getJSONArray("stringArrayValue"); assertEquals(2, jsonArray.length()); assertEquals("first", jsonArray.getString(0)); assertEquals("second", jsonArray.getString(1)); jsonArray = json.getJSONArray("stringArrayListValue"); assertEquals(3, jsonArray.length()); assertEquals("1st", jsonArray.getString(0)); assertEquals("2nd", jsonArray.getString(1)); assertEquals("third", jsonArray.getString(2)); JSONObject innerJson = json.getJSONObject("nested"); assertEquals(1, innerJson.getInt("inner")); innerJson = innerJson.getJSONObject("nested bundle"); assertEquals("2", innerJson.getString("inner")); jsonArray = innerJson.getJSONArray("deep list"); assertEquals(2, jsonArray.length()); assertEquals("7", jsonArray.getString(0)); assertEquals("8", jsonArray.getString(1)); Bundle finalBundle = BundleJSONConverter.convertToBundle(json); assertNotNull(finalBundle); assertEquals(true, finalBundle.getBoolean("boolValue")); assertEquals(7, finalBundle.getInt("intValue")); assertEquals(5000000000l, finalBundle.getLong("longValue")); assertEquals(3.14, finalBundle.getDouble("doubleValue")); assertEquals("hello world", finalBundle.getString("stringValue")); List<String> stringList = finalBundle.getStringArrayList("stringArrayValue"); assertEquals(2, stringList.size()); assertEquals("first", stringList.get(0)); assertEquals("second", stringList.get(1)); stringList = finalBundle.getStringArrayList("stringArrayListValue"); assertEquals(3, stringList.size()); assertEquals("1st", stringList.get(0)); assertEquals("2nd", stringList.get(1)); assertEquals("third", stringList.get(2)); Bundle finalInnerBundle = finalBundle.getBundle("nested"); assertEquals(1, finalInnerBundle.getInt("inner")); finalBundle = finalInnerBundle.getBundle("nested bundle"); assertEquals("2", finalBundle.getString("inner")); stringList = finalBundle.getStringArrayList("deep list"); assertEquals(2, stringList.size()); assertEquals("7", stringList.get(0)); assertEquals("8", stringList.get(1)); }