/** The state is restored so the player can continue playing */
 @Override
 public void onRestoreInstanceState(Bundle inState) {
   super.onRestoreInstanceState(inState);
   evilType = inState.getBoolean("evil");
   char guessed[] = inState.getCharArray("guessed");
   char letters[] = inState.getCharArray("letters");
   int score = inState.getInt("score");
   int left = inState.getInt("left");
   int set = inState.getInt("setGuesses");
   final HangmanLexicon lexicon = (HangmanLexicon) getApplicationContext();
   // the correct type of game is created
   if (evilType) {
     ArrayList<String> words = (ArrayList<String>) inState.getSerializable("words");
     game = new EvilGameplay(words, guessed, letters, left, score, set, lexicon);
   } else {
     String word = inState.getString("word");
     game = new GoodGameplay(word, guessed, letters, left, score, set, lexicon);
   }
   setText();
 }
  @SmallTest
  @MediumTest
  @LargeTest
  public void testAllTypes() {
    Bundle originalBundle = new Bundle();

    putBoolean(BOOLEAN_KEY, originalBundle);
    putBooleanArray(BOOLEAN_ARRAY_KEY, originalBundle);
    putByte(BYTE_KEY, originalBundle);
    putByteArray(BYTE_ARRAY_KEY, originalBundle);
    putShort(SHORT_KEY, originalBundle);
    putShortArray(SHORT_ARRAY_KEY, originalBundle);
    putInt(INT_KEY, originalBundle);
    putIntArray(INT_ARRAY_KEY, originalBundle);
    putLong(LONG_KEY, originalBundle);
    putLongArray(LONG_ARRAY_KEY, originalBundle);
    putFloat(FLOAT_KEY, originalBundle);
    putFloatArray(FLOAT_ARRAY_KEY, originalBundle);
    putDouble(DOUBLE_KEY, originalBundle);
    putDoubleArray(DOUBLE_ARRAY_KEY, originalBundle);
    putChar(CHAR_KEY, originalBundle);
    putCharArray(CHAR_ARRAY_KEY, originalBundle);
    putString(STRING_KEY, originalBundle);
    putStringList(STRING_LIST_KEY, originalBundle);
    originalBundle.putSerializable(SERIALIZABLE_KEY, AccessTokenSource.FACEBOOK_APPLICATION_WEB);

    ensureApplicationContext();

    SharedPreferencesTokenCachingStrategy cache =
        new SharedPreferencesTokenCachingStrategy(getContext());
    cache.save(originalBundle);

    SharedPreferencesTokenCachingStrategy cache2 =
        new SharedPreferencesTokenCachingStrategy(getContext());
    Bundle cachedBundle = cache2.load();

    Assert.assertEquals(
        originalBundle.getBoolean(BOOLEAN_KEY), cachedBundle.getBoolean(BOOLEAN_KEY));
    assertArrayEquals(
        originalBundle.getBooleanArray(BOOLEAN_ARRAY_KEY),
        cachedBundle.getBooleanArray(BOOLEAN_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getByte(BYTE_KEY), cachedBundle.getByte(BYTE_KEY));
    assertArrayEquals(
        originalBundle.getByteArray(BYTE_ARRAY_KEY), cachedBundle.getByteArray(BYTE_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getShort(SHORT_KEY), cachedBundle.getShort(SHORT_KEY));
    assertArrayEquals(
        originalBundle.getShortArray(SHORT_ARRAY_KEY), cachedBundle.getShortArray(SHORT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getInt(INT_KEY), cachedBundle.getInt(INT_KEY));
    assertArrayEquals(
        originalBundle.getIntArray(INT_ARRAY_KEY), cachedBundle.getIntArray(INT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getLong(LONG_KEY), cachedBundle.getLong(LONG_KEY));
    assertArrayEquals(
        originalBundle.getLongArray(LONG_ARRAY_KEY), cachedBundle.getLongArray(LONG_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getFloat(FLOAT_KEY), cachedBundle.getFloat(FLOAT_KEY));
    assertArrayEquals(
        originalBundle.getFloatArray(FLOAT_ARRAY_KEY), cachedBundle.getFloatArray(FLOAT_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getDouble(DOUBLE_KEY), cachedBundle.getDouble(DOUBLE_KEY));
    assertArrayEquals(
        originalBundle.getDoubleArray(DOUBLE_ARRAY_KEY),
        cachedBundle.getDoubleArray(DOUBLE_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getChar(CHAR_KEY), cachedBundle.getChar(CHAR_KEY));
    assertArrayEquals(
        originalBundle.getCharArray(CHAR_ARRAY_KEY), cachedBundle.getCharArray(CHAR_ARRAY_KEY));
    Assert.assertEquals(originalBundle.getString(STRING_KEY), cachedBundle.getString(STRING_KEY));
    assertListEquals(
        originalBundle.getStringArrayList(STRING_LIST_KEY),
        cachedBundle.getStringArrayList(STRING_LIST_KEY));
    Assert.assertEquals(
        originalBundle.getSerializable(SERIALIZABLE_KEY),
        cachedBundle.getSerializable(SERIALIZABLE_KEY));
  }
 public char[] getCharArray(Bundle bundle) {
   return bundle == null ? null : bundle.getCharArray(getName());
 }
 /**
  * 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);
 }