@Test public void charArray() { char [] arr = new char[] { 'c', 'j' }; bundle.putCharArray("foo", arr); assertThat(bundle.getCharArray("foo")).isEqualTo(arr); assertThat(bundle.getCharArray("bar")).isNull(); }
when(bundle.getCharArray(anyString())).thenAnswer(get);
@Test public void getWrongType() { bundle.putFloat("foo", 5f); assertThat(bundle.getCharArray("foo")).isNull(); assertThat(bundle.getInt("foo")).isEqualTo(0); assertThat(bundle.getIntArray("foo")).isNull(); assertThat(bundle.getIntegerArrayList("foo")).isNull(); assertThat(bundle.getShort("foo")).isEqualTo((short) 0); assertThat(bundle.getShortArray("foo")).isNull(); assertThat(bundle.getBoolean("foo")).isFalse(); assertThat(bundle.getBooleanArray("foo")).isNull(); assertThat(bundle.getLong("foo")).isEqualTo(0); assertThat(bundle.getLongArray("foo")).isNull(); assertThat(bundle.getFloatArray("foo")).isNull(); assertThat(bundle.getDouble("foo")).isEqualTo(0.0); assertThat(bundle.getDoubleArray("foo")).isNull(); assertThat(bundle.getString("foo")).isNull(); assertThat(bundle.getStringArray("foo")).isNull(); assertThat(bundle.getStringArrayList("foo")).isNull(); assertThat(bundle.getBundle("foo")).isNull(); assertThat((Parcelable) bundle.getParcelable("foo")).isNull(); assertThat(bundle.getParcelableArray("foo")).isNull(); assertThat(bundle.getParcelableArrayList("foo")).isNull(); bundle.putInt("foo", 1); assertThat(bundle.getFloat("foo")).isEqualTo(0.0f); }
assertArrayEquals(originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY), cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY)); assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY)); assertArrayEquals(originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY)); assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY)); assertListEquals(originalBundle.getStringArrayList(STRING_LIST_KEY), cachedBundle.getStringArrayList(
/** * Retrieve extended data from the request. * * @param name The name of the desired item. * @return the value of an item that previously added with putExtra() or * null if no char array value was found. * @see #putExtra(String, char[]) */ public char[] getCharArrayExtra(String name) { return mExtras == null ? null : mExtras.getCharArray(name); }
public char[] getChars(String key){ if (mBundle != null) { return mBundle.getCharArray(key); } return null; }
public char[] getCharArray(Bundle state, String key) { return state.getCharArray(key + mBaseKey); }
@Override public String get(Bundle bundle, String data, String keyPrefix) { char[] inArray = bundle.getCharArray(keyPrefix); char[] outArray = new char[inArray.length - keyPrefix.length()]; System.arraycopy(inArray, keyPrefix.length(), outArray, 0, outArray.length); return new String(outArray); }