List of usage examples for android.os Bundle putStringArray
public void putStringArray(@Nullable String key, @Nullable String[] value)
From source file:com.facebook.internal.BundleJSONConverterTest.java
@Test 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);/*w ww. j a va 2 s . co m*/ assertEquals(true, json.getBoolean("boolValue")); assertEquals(7, json.getInt("intValue")); assertEquals(5000000000l, json.getLong("longValue")); assertEquals(3.14, json.getDouble("doubleValue"), TestUtils.DOUBLE_EQUALS_DELTA); 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"), TestUtils.DOUBLE_EQUALS_DELTA); 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)); }
From source file:com.example.captain_miao.grantap.ShadowPermissionActivity.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putStringArray(EXTRA_PERMISSIONS, permissions); outState.putString(EXTRA_RATIONALE_MESSAGE, rationale_message); outState.putString(EXTRA_DENY_MESSAGE, denyMessage); outState.putString(EXTRA_PACKAGE_NAME, packageName); outState.putBoolean(EXTRA_SETTING_BUTTON, hasSettingButton); outState.putString(EXTRA_SETTING_BUTTON, deniedCloseButtonText); outState.putString(EXTRA_RATIONALE_CONFIRM_TEXT, rationaleConfirmText); super.onSaveInstanceState(outState); }
From source file:org.voidsink.anewjkuapp.TermTabItem.java
protected Bundle getArguments() { Bundle b = new Bundle(); if (mTerms != null) { String[] mTermStrings = new String[mTerms.size()]; for (int i = 0; i < mTerms.size(); i++) { mTermStrings[i] = mTerms.get(i).toString(); }//from w w w. j a va 2 s. c o m b.putStringArray(Consts.ARG_TERMS, mTermStrings); } return b; }
From source file:com.dm.material.dashboard.candybar.fragments.dialog.InAppBillingFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putInt(TYPE, mType);//from ww w. j a v a 2 s . c o m outState.putString(KEY, mKey); outState.putStringArray(PRODUCT_ID, mProductsId); outState.putIntArray(PRODUCT_COUNT, mProductsCount); super.onSaveInstanceState(outState); }
From source file:de.aw.monma.snippets.SnippetRegelmBuchungen.java
@Override protected void setInternalArguments(Bundle args) { super.setInternalArguments(args); args.putParcelable(DBDEFINITION, tbd); args.putIntArray(VIEWRESIDS, viewResIDs); args.putInt(VIEWHOLDERLAYOUT, detailView); args.putStringArray(PROJECTION, projection); args.putString(SELECTION, selection); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, 5); Date date = cal.getTime();/*from w ww . j a va 2 s. c o m*/ String[] selectionArgs = { DBConvert.convertDate2SQLiteDate(date) }; args.putStringArray(SELECTIONARGS, selectionArgs); }
From source file:android.support.content.ContentPager.java
/** * @return Bundle populated with existing extras (if any) as well as * all usefule paging related extras./*from w ww. j ava 2s. c om*/ */ static Bundle buildExtras(@Nullable Bundle extras, int recordCount, @CursorDisposition int cursorDisposition) { if (extras == null || extras == Bundle.EMPTY) { extras = new Bundle(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { extras = extras.deepCopy(); } // else we modify cursor extras directly, cuz that's our only choice. extras.putInt(CURSOR_DISPOSITION, cursorDisposition); if (!extras.containsKey(EXTRA_TOTAL_COUNT)) { extras.putInt(EXTRA_TOTAL_COUNT, recordCount); } if (!extras.containsKey(EXTRA_HONORED_ARGS)) { extras.putStringArray(EXTRA_HONORED_ARGS, new String[] { ContentPager.QUERY_ARG_OFFSET, ContentPager.QUERY_ARG_LIMIT }); } return extras; }
From source file:net.simonvt.cathode.util.FragmentStack.java
public Bundle saveState() { commit();//from www . j a v a2 s .co m final int stackSize = stack.size(); String[] stackTags = new String[stackSize]; int i = 0; for (Fragment f : stack) { stackTags[i++] = f.getTag(); } Bundle outState = new Bundle(); outState.putStringArray(STATE_STACK, stackTags); return outState; }
From source file:es.jpv.android.examples.loadersexample.MainActivityFragment.java
/** * <p>Endless RecyclerView page loader</p> * * When a RecyclerView is scrolled until its end this method is invoked to load more rows */// w ww. j a v a2s . c om @Override public void loadMore() { Bundle loaderArgs = new Bundle(); loaderArgs.putString("Table", DataProviderContract.ITEMS_TABLE_NAME); loaderArgs.putStringArray("Projection", PROJECTION); loaderArgs.putString("Order", BaseColumns._ID); loaderArgs.putLong("Limit", lastLimitLoaded); getLoaderManager().restartLoader(LOADER_ID, loaderArgs, new DBSelectLoader()); }
From source file:es.jpv.android.examples.loadersexample.MainActivityFragment.java
/** * Initiates the Loader to perform the first load of data onto the RecyclerView */// w w w .j ava 2s . co m @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Bundle loaderArgs = new Bundle(); loaderArgs.putString("Table", DataProviderContract.ITEMS_TABLE_NAME); loaderArgs.putStringArray("Projection", PROJECTION); loaderArgs.putString("Order", BaseColumns._ID); loaderArgs.putLong("Limit", lastLimitLoaded); getLoaderManager().initLoader(LOADER_ID, loaderArgs, new DBSelectLoader()); }
From source file:de.aw.monma.mainscreen.FragmentPassport.java
@Override protected void setInternalArguments(Bundle args) { super.setInternalArguments(args); args.putInt(LAYOUT, layout);//w w w .ja v a 2 s .c om args.putParcelable(DBDEFINITION, tbd); args.putStringArray(PROJECTION, projection); args.putInt(VIEWHOLDERLAYOUT, viewHolderLayout); zeigeDetails = prefs.getBoolean(getString(R.string.cbDetailAnzeigeBank), true); }