Example usage for android.os Bundle putBundle

List of usage examples for android.os Bundle putBundle

Introduction

In this page you can find the example usage for android.os Bundle putBundle.

Prototype

public void putBundle(@Nullable String key, @Nullable Bundle value) 

Source Link

Document

Inserts a Bundle value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ??//www  .j a va  2s.  co  m
 *
 * @param outState Bundle
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    Object o = f.get(this);
                    if (o == null) {
                        continue;
                    }
                    String fieldName = f.getName();
                    if (o instanceof Integer) {
                        outState.putInt(fieldName, f.getInt(this));
                    } else if (o instanceof String) {
                        outState.putString(fieldName, (String) f.get(this));
                    } else if (o instanceof Long) {
                        outState.putLong(fieldName, f.getLong(this));
                    } else if (o instanceof Short) {
                        outState.putShort(fieldName, f.getShort(this));
                    } else if (o instanceof Boolean) {
                        outState.putBoolean(fieldName, f.getBoolean(this));
                    } else if (o instanceof Byte) {
                        outState.putByte(fieldName, f.getByte(this));
                    } else if (o instanceof Character) {
                        outState.putChar(fieldName, f.getChar(this));
                    } else if (o instanceof CharSequence) {
                        outState.putCharSequence(fieldName, (CharSequence) f.get(this));
                    } else if (o instanceof Float) {
                        outState.putFloat(fieldName, f.getFloat(this));
                    } else if (o instanceof Double) {
                        outState.putDouble(fieldName, f.getDouble(this));
                    } else if (o instanceof String[]) {
                        outState.putStringArray(fieldName, (String[]) f.get(this));
                    } else if (o instanceof Parcelable) {
                        outState.putParcelable(fieldName, (Parcelable) f.get(this));
                    } else if (o instanceof Serializable) {
                        outState.putSerializable(fieldName, (Serializable) f.get(this));
                    } else if (o instanceof Bundle) {
                        outState.putBundle(fieldName, (Bundle) f.get(this));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    super.onSaveInstanceState(outState);
}

From source file:com.free.searcher.MainFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.i("SearcheFragment.onSaveInstanceState();", outState + ", " + actionBar.getTabCount());
    outState.putInt("level selected", actionBar.getSelectedNavigationIndex());
    outState.putStringArray("selectedFiles", selectedFiles);

    outState.putSerializable("files", files);

    outState.putString("currentZipFileName", currentZipFileName);
    if (extractFile != null) {
        extractFile.close();// w  ww . ja  v a 2  s . c o m
    }
    outState.putString("currentSearching", currentSearching);

    outState.putString("load", load);

    Log.d("load", load + " xxx");
    outState.putString("currentUrl", currentUrl);
    //      outState.putString("source", HtmlSourceViewJavaScriptInterface.source);
    outState.putCharSequence("query",
            (mSearchView != null && mSearchView.getQuery() != null) ? mSearchView.getQuery() : "");
    status = statusView.getText();
    outState.putCharSequence("status", status);

    locX = webView.getScrollX();
    outState.putInt("locX", locX);
    locY = webView.getScrollY();
    outState.putInt("locY", locY);

    outState.putString("home", home);

    webView.saveState((webViewBundle = new Bundle()));
    outState.putBundle("webViewBundle", webViewBundle);
    Log.d("frag.onSaveInstanceState();", outState + "");
    /**
     try {
     outState.putString("readTextFiles", Util.listToString(readTextFiles, false, ";;;"));
     outState.putString("initFolderFiles", Util.listToString(initFolderFiles, false, ";;;"));
     } catch (Throwable t) {
     t.printStackTrace();
     }
     **/
}

From source file:org.cafemember.ui.LaunchActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    try {//  w  w  w.j ava 2 s  . co m
        super.onSaveInstanceState(outState);
        BaseFragment lastFragment = null;
        if (AndroidUtilities.isTablet()) {
            if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
                lastFragment = layersActionBarLayout.fragmentsStack
                        .get(layersActionBarLayout.fragmentsStack.size() - 1);
            } else if (!rightActionBarLayout.fragmentsStack.isEmpty()) {
                lastFragment = rightActionBarLayout.fragmentsStack
                        .get(rightActionBarLayout.fragmentsStack.size() - 1);
            } else if (!actionBarLayout.fragmentsStack.isEmpty()) {
                lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
            }
        } else {
            if (!actionBarLayout.fragmentsStack.isEmpty()) {
                lastFragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1);
            }
        }

        if (lastFragment != null) {
            Bundle args = lastFragment.getArguments();
            if (lastFragment instanceof ChatActivity && args != null) {
                outState.putBundle("args", args);
                outState.putString("fragment", "chat");
            } else if (lastFragment instanceof SettingsActivity) {
                outState.putString("fragment", "settings");
            } else if (lastFragment instanceof GroupCreateFinalActivity && args != null) {
                outState.putBundle("args", args);
                outState.putString("fragment", "group");
            } else if (lastFragment instanceof WallpapersActivity) {
                outState.putString("fragment", "wallpapers");
            } else if (lastFragment instanceof ProfileActivity && ((ProfileActivity) lastFragment).isChat()
                    && args != null) {
                outState.putBundle("args", args);
                outState.putString("fragment", "chat_profile");
            } else if (lastFragment instanceof ChannelCreateActivity && args != null
                    && args.getInt("step") == 0) {
                outState.putBundle("args", args);
                outState.putString("fragment", "channel");
            } else if (lastFragment instanceof ChannelEditActivity && args != null) {
                outState.putBundle("args", args);
                outState.putString("fragment", "edit");
            }
            lastFragment.saveSelfArgs(outState);
        }
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}

From source file:com.shurik.droidzebra.ZebraEngine.java

private JSONObject Callback(int msgcode, JSONObject data) {
    JSONObject retval = null;/*  ww w . j a  va  2s  .c  om*/
    Message msg = mHandler.obtainMessage(msgcode);
    Bundle b = new Bundle();
    msg.setData(b);
    // Log.d("ZebraEngine", String.format("Callback(%d,%s)", msgcode, data.toString()));
    if (bInCallback)
        fatalError("Recursive vallback call");
    try {
        bInCallback = true;
        switch (msgcode) {
        case MSG_ERROR: {
            b.putString("error", data.getString("error"));
            if (getEngineState() == ES_INITIAL) {
                // delete .bin files if initialization failed
                // will be recreated from resources
                new File(mFilesDir, PATTERNS_FILE).delete();
                new File(mFilesDir, BOOK_FILE).delete();
                new File(mFilesDir, BOOK_FILE_COMPRESSED).delete();
            }
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_DEBUG: {
            b.putString("message", data.getString("message"));
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_BOARD: {
            int len;
            JSONObject info;
            JSONArray zeArray;
            byte[] moves;

            JSONArray zeboard = data.getJSONArray("board");
            byte newBoard[] = new byte[BOARD_SIZE * BOARD_SIZE];
            for (int i = 0; i < zeboard.length(); i++) {
                JSONArray row = zeboard.getJSONArray(i);
                for (int j = 0; j < row.length(); j++) {
                    newBoard[i * BOARD_SIZE + j] = (byte) row.getInt(j);
                }
            }
            b.putByteArray("board", newBoard);
            b.putInt("side_to_move", data.getInt("side_to_move"));
            mCurrentGameState.mDisksPlayed = data.getInt("disks_played");

            // black info
            {
                Bundle black = new Bundle();
                info = data.getJSONObject("black");
                black.putString("time", info.getString("time"));
                black.putFloat("eval", (float) info.getDouble("eval"));
                black.putInt("disc_count", info.getInt("disc_count"));
                black.putString("time", info.getString("time"));

                zeArray = info.getJSONArray("moves");
                len = zeArray.length();
                moves = new byte[len];
                assert (2 * len <= mCurrentGameState.mMoveSequence.length);
                for (int i = 0; i < len; i++) {
                    moves[i] = (byte) zeArray.getInt(i);
                    mCurrentGameState.mMoveSequence[2 * i] = moves[i];
                }
                black.putByteArray("moves", moves);
                b.putBundle("black", black);
            }

            // white info
            {
                Bundle white = new Bundle();
                info = data.getJSONObject("white");
                white.putString("time", info.getString("time"));
                white.putFloat("eval", (float) info.getDouble("eval"));
                white.putInt("disc_count", info.getInt("disc_count"));
                white.putString("time", info.getString("time"));

                zeArray = info.getJSONArray("moves");
                len = zeArray.length();
                moves = new byte[len];
                assert ((2 * len + 1) <= mCurrentGameState.mMoveSequence.length);
                for (int i = 0; i < len; i++) {
                    moves[i] = (byte) zeArray.getInt(i);
                    mCurrentGameState.mMoveSequence[2 * i + 1] = moves[i];
                }
                white.putByteArray("moves", moves);
                b.putBundle("white", white);
            }

            mHandler.sendMessage(msg);
        }
            break;

        case MSG_CANDIDATE_MOVES: {
            JSONArray jscmoves = data.getJSONArray("moves");
            CandidateMove cmoves[] = new CandidateMove[jscmoves.length()];
            mValidMoves = new int[jscmoves.length()];
            for (int i = 0; i < jscmoves.length(); i++) {
                JSONObject jscmove = jscmoves.getJSONObject(i);
                mValidMoves[i] = jscmoves.getJSONObject(i).getInt("move");
                cmoves[i] = new CandidateMove(new Move(jscmove.getInt("move")));
            }
            msg.obj = cmoves;
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_GET_USER_INPUT: {
            mMovesWithoutInput = 0;

            setEngineState(ES_USER_INPUT_WAIT);

            waitForEngineState(ES_PLAY);

            while (mPendingEvent == null) {
                setEngineState(ES_USER_INPUT_WAIT);
                waitForEngineState(ES_PLAY);
            }

            retval = mPendingEvent;

            setEngineState(ES_PLAYINPROGRESS);

            mValidMoves = null;
            mPendingEvent = null;
        }
            break;

        case MSG_PASS: {
            setEngineState(ES_USER_INPUT_WAIT);
            mHandler.sendMessage(msg);
            waitForEngineState(ES_PLAY);
            setEngineState(ES_PLAYINPROGRESS);
        }
            break;

        case MSG_OPENING_NAME: {
            b.putString("opening", data.getString("opening"));
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_LAST_MOVE: {
            b.putInt("move", data.getInt("move"));
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_GAME_START: {
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_GAME_OVER: {
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_MOVE_START: {
            mMoveStartTime = android.os.SystemClock.uptimeMillis();

            mSideToMove = data.getInt("side_to_move");

            // can change player info here
            if (mPlayerInfoChanged) {
                zeSetPlayerInfo(PLAYER_BLACK, mPlayerInfo[PLAYER_BLACK].skill,
                        mPlayerInfo[PLAYER_BLACK].exactSolvingSkill, mPlayerInfo[PLAYER_BLACK].wldSolvingSkill,
                        mPlayerInfo[PLAYER_BLACK].playerTime, mPlayerInfo[PLAYER_BLACK].playerTimeIncrement);
                zeSetPlayerInfo(PLAYER_WHITE, mPlayerInfo[PLAYER_WHITE].skill,
                        mPlayerInfo[PLAYER_WHITE].exactSolvingSkill, mPlayerInfo[PLAYER_WHITE].wldSolvingSkill,
                        mPlayerInfo[PLAYER_WHITE].playerTime, mPlayerInfo[PLAYER_WHITE].playerTimeIncrement);
                zeSetPlayerInfo(PLAYER_ZEBRA, mPlayerInfo[PLAYER_ZEBRA].skill,
                        mPlayerInfo[PLAYER_ZEBRA].exactSolvingSkill, mPlayerInfo[PLAYER_ZEBRA].wldSolvingSkill,
                        mPlayerInfo[PLAYER_ZEBRA].playerTime, mPlayerInfo[PLAYER_ZEBRA].playerTimeIncrement);
            }
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_MOVE_END: {
            // introduce delay between moves made by the computer without user input
            // so we can actually to see that the game is being played :)
            if (mMoveDelay > 0 || (mMovesWithoutInput > 1 && mPlayerInfo[mSideToMove].skill > 0)) {
                long moveEnd = android.os.SystemClock.uptimeMillis();
                int delay = mMoveDelay > 0 ? mMoveDelay : SELFPLAY_MOVE_DELAY;
                if ((moveEnd - mMoveStartTime) < delay) {
                    android.os.SystemClock.sleep(delay - (moveEnd - mMoveStartTime));
                }
            }

            // this counter is reset by user input
            mMovesWithoutInput += 1;

            mHandler.sendMessage(msg);
        }
            break;

        case MSG_EVAL_TEXT: {
            b.putString("eval", data.getString("eval"));
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_PV: {
            JSONArray zeArray = data.getJSONArray("pv");
            int len = zeArray.length();
            byte[] moves = new byte[len];
            for (int i = 0; i < len; i++)
                moves[i] = (byte) zeArray.getInt(i);
            b.putByteArray("pv", moves);
            mHandler.sendMessage(msg);
        }
            break;

        case MSG_CANDIDATE_EVALS: {
            JSONArray jscevals = data.getJSONArray("evals");
            CandidateMove cmoves[] = new CandidateMove[jscevals.length()];
            for (int i = 0; i < jscevals.length(); i++) {
                JSONObject jsceval = jscevals.getJSONObject(i);
                cmoves[i] = new CandidateMove(new Move(jsceval.getInt("move")), jsceval.getString("eval_s"),
                        jsceval.getString("eval_l"), (jsceval.getInt("best") != 0));
            }
            msg.obj = cmoves;
            mHandler.sendMessage(msg);

        }
            break;

        default: {
            b.putString("error", String.format("Unkown message ID %d", msgcode));
            msg.setData(b);
            mHandler.sendMessage(msg);
        }
            break;
        }
    } catch (JSONException e) {
        msg.what = MSG_ERROR;
        b.putString("error", "JSONException:" + e.getMessage());
        msg.setData(b);
        mHandler.sendMessage(msg);
    } finally {
        bInCallback = false;
    }
    return retval;
}

From source file:com.android.mail.compose.ComposeActivity.java

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    final Bundle inner = new Bundle();
    saveState(inner);/*from  w ww  .ja  v  a 2s .  c  o  m*/
    state.putBundle(KEY_INNER_SAVED_STATE, inner);
}

From source file:br.org.funcate.dynamicforms.FragmentDetailActivity.java

private void saveAction() throws Exception {

    FragmentDetail detailFragment = (FragmentDetail) getSupportFragmentManager()
            .findFragmentById(R.id.detailFragment);
    if (detailFragment != null) {
        detailFragment.storeFormItems(false);
    }//from ww w .j a va2s  . c o m

    if (sectionObject == null) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }

    // extract and check constraints
    List<String> availableFormNames = TagsManager.getFormNames4Section(sectionObject);
    Bundle formData = null;

    if (availableFormNames.isEmpty()) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }

    for (String formNameIt : availableFormNames) {
        JSONObject formObject = TagsManager.getForm4Name(formNameIt, sectionObject);
        JSONArray formItemsArray = TagsManager.getFormItems(formObject);

        int length = formItemsArray != null ? formItemsArray.length() : 0;
        formData = new Bundle(length);
        ArrayList<String> keys = new ArrayList<String>(length);
        ArrayList<String> types = new ArrayList<String>(length);

        String key = "";
        String value = "";
        String type = "";
        boolean insertKey;// This control flag is used to ignore some types because are simply ignored or are manipulated in other time.

        for (int i = 0; i < length; i++) {
            JSONObject jsonObject = formItemsArray.getJSONObject(i);

            if (jsonObject.has(TAG_KEY))
                key = jsonObject.getString(TAG_KEY).trim();

            if (jsonObject.has(TAG_VALUE)) {
                value = jsonObject.getString(TAG_VALUE).trim();
            }

            if (jsonObject.has(TAG_TYPE)) {
                type = jsonObject.getString(TAG_TYPE).trim();
            }

            if (!key.equals("") && !value.equals("") && !type.equals("")) {

                insertKey = true;

                if (type.equals(TYPE_STRING)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_STRINGAREA)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_DOUBLE)) {
                    formData.putDouble(key, Double.valueOf(value));
                } else if (type.equals(TYPE_INTEGER)) {
                    formData.putInt(key, Integer.valueOf(value));
                } else if (type.equals(TYPE_DATE)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_TIME)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_LABEL)) {
                    insertKey = false;
                    //formData.putString(key, value);
                } else if (type.equals(TYPE_LABELWITHLINE)) {
                    insertKey = false;
                    //formData.putString(key, value);
                } else if (type.equals(TYPE_BOOLEAN)) {
                    formData.putBoolean(key, Boolean.valueOf(value));
                } else if (type.equals(TYPE_STRINGCOMBO)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_CONNECTEDSTRINGCOMBO)) {
                    formData.putString(key, value);
                } else if (type.equals(TYPE_STRINGMULTIPLECHOICE)) {
                    insertKey = false;
                    //formData.putString(key,value);
                } else if (type.equals(TYPE_PICTURES)) {
                    insertKey = false;
                    // Using the new key to represent a list of image paths. It is manipulated on posterior time.
                    //formData.putString(key,value);
                    decodeFromJson(value, formData);
                }

                if (insertKey) {
                    keys.add(key);
                    types.add(type);
                }

            }
        }
        formData.putStringArrayList(LibraryConstants.FORM_TYPES, types);
        formData.putStringArrayList(LibraryConstants.FORM_KEYS, keys);

        if (sectionObject.has(FormUtilities.ATTR_GEOJSON_TAGS)) {
            JSONObject geojsonGeometry = sectionObject.getJSONObject(FormUtilities.ATTR_GEOJSON_TAGS);
            formData.putString(FormUtilities.ATTR_GEOJSON_TAGS, geojsonGeometry.toString());
        }

        if (pointId >= 0) {
            formData.putLong(FormUtilities.GEOM_ID, pointId);
        }

        if (existingFeatureData != null) {
            formData.putBundle(FormUtilities.ATTR_DATA_VALUES, existingFeatureData);
        }
    }

    if (formData == null) {
        throw new Exception(this.getString(R.string.session_object_exception));
    }
    Intent intent = getIntent();
    intent.putExtra(LibraryConstants.PREFS_KEY_FORM, formData);
    setResult(Activity.RESULT_OK, intent);
    finish();
}

From source file:de.mrapp.android.adapter.expandablelist.AbstractExpandableListAdapter.java

@Override
public final void onSaveInstanceState(@NonNull final Bundle outState, @NonNull final String key) {
    Bundle savedState = new Bundle();
    groupAdapter.onSaveInstanceState(savedState, GROUP_ADAPTER_BUNDLE_KEY);

    if (savedState.containsKey(GROUP_ADAPTER_BUNDLE_KEY)) {
        for (int i = 0; i < groupAdapter.getCount(); i++) {
            MultipleChoiceListAdapter<ChildType> childAdapter = groupAdapter.getItem(i).getChildAdapter();

            if (childAdapter != null) {
                String childAdapterKey = String.format(CHILD_ADAPTER_BUNDLE_KEY, i);
                childAdapter.onSaveInstanceState(savedState, childAdapterKey);
            }/*from w ww.jav  a 2 s  . co  m*/
        }
    }

    if (adapterView != null) {
        AdapterViewUtil.onSaveInstanceState(adapterView, savedState, ADAPTER_VIEW_STATE_BUNDLE_KEY);
    } else if (expandableGridView != null) {
        AdapterViewUtil.onSaveInstanceState(expandableGridView, savedState, ADAPTER_VIEW_STATE_BUNDLE_KEY);
    } else if (expandableRecyclerView != null) {
        RecyclerView.LayoutManager layoutManager = expandableRecyclerView.getLayoutManager();

        if (layoutManager != null) {
            savedState.putParcelable(ADAPTER_VIEW_STATE_BUNDLE_KEY, layoutManager.onSaveInstanceState());
        }
    } else {
        String message = "The state of the adapter view can not be stored, because the "
                + "adapter has not been attached to a view";
        getLogger().logWarn(getClass(), message);
    }

    savedState.putBoolean(ALLOW_DUPLICATE_CHILDREN_BUNDLE_KEY, areDuplicateChildrenAllowed());
    savedState.putBoolean(TRIGGER_GROUP_EXPANSION_ON_CLICK_BUNDLE_KEY, isGroupExpansionTriggeredOnClick());
    savedState.putInt(LOG_LEVEL_BUNDLE_KEY, getLogLevel().getRank());
    onSaveInstanceState(savedState);
    outState.putBundle(key, savedState);
    getLogger().logDebug(getClass(), "Saved instance state");
}

From source file:android.app.Activity.java

/**
 * Called to retrieve per-instance state from an activity before being killed
 * so that the state can be restored in {@link #onCreate} or
 * {@link #onRestoreInstanceState} (the {@link Bundle} populated by this method
 * will be passed to both).//from  w  w  w  .  j a  v a2 s.  c om
 *
 * <p>This method is called before an activity may be killed so that when it
 * comes back some time in the future it can restore its state.  For example,
 * if activity B is launched in front of activity A, and at some point activity
 * A is killed to reclaim resources, activity A will have a chance to save the
 * current state of its user interface via this method so that when the user
 * returns to activity A, the state of the user interface can be restored
 * via {@link #onCreate} or {@link #onRestoreInstanceState}.
 *
 * <p>Do not confuse this method with activity lifecycle callbacks such as
 * {@link #onPause}, which is always called when an activity is being placed
 * in the background or on its way to destruction, or {@link #onStop} which
 * is called before destruction.  One example of when {@link #onPause} and
 * {@link #onStop} is called and not this method is when a user navigates back
 * from activity B to activity A: there is no need to call {@link #onSaveInstanceState}
 * on B because that particular instance will never be restored, so the
 * system avoids calling it.  An example when {@link #onPause} is called and
 * not {@link #onSaveInstanceState} is when activity B is launched in front of activity A:
 * the system may avoid calling {@link #onSaveInstanceState} on activity A if it isn't
 * killed during the lifetime of B since the state of the user interface of
 * A will stay intact.
 *
 * <p>The default implementation takes care of most of the UI per-instance
 * state for you by calling {@link android.view.View#onSaveInstanceState()} on each
 * view in the hierarchy that has an id, and by saving the id of the currently
 * focused view (all of which is restored by the default implementation of
 * {@link #onRestoreInstanceState}).  If you override this method to save additional
 * information not captured by each individual view, you will likely want to
 * call through to the default implementation, otherwise be prepared to save
 * all of the state of each view yourself.
 *
 * <p>If called, this method will occur before {@link #onStop}.  There are
 * no guarantees about whether it will occur before or after {@link #onPause}.
 * 
 * @param outState Bundle in which to place your saved state.
 * 
 * @see #onCreate
 * @see #onRestoreInstanceState
 * @see #onPause
 */
protected void onSaveInstanceState(Bundle outState) {

    outState.putBundle(WINDOW_HIERARCHY_TAG, mWindow.saveHierarchyState());
    Parcelable p = mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    getApplication().dispatchActivitySaveInstanceState(this, outState);
}

From source file:com.chen.mail.ui.AbstractActivityController.java

@Override
public void onSaveInstanceState(Bundle outState) {
    mViewMode.handleSaveInstanceState(outState);
    if (mAccount != null) {
        outState.putParcelable(SAVED_ACCOUNT, mAccount);
    }//from w w w .ja va2 s.c  om
    if (mFolder != null) {
        outState.putParcelable(SAVED_FOLDER, mFolder);
    }
    // If this is a search activity, let's store the search query term as well.
    if (ConversationListContext.isSearchResult(mConvListContext)) {
        outState.putString(SAVED_QUERY, mConvListContext.searchQuery);
    }
    if (mCurrentConversation != null && mViewMode.isConversationMode()) {
        outState.putParcelable(SAVED_CONVERSATION, mCurrentConversation);
    }
    if (!mSelectedSet.isEmpty()) {
        outState.putParcelable(SAVED_SELECTED_SET, mSelectedSet);
    }
    if (mToastBar.getVisibility() == View.VISIBLE) {
        outState.putParcelable(SAVED_TOAST_BAR_OP, mToastBar.getOperation());
    }
    final ConversationListFragment convListFragment = getConversationListFragment();
    if (convListFragment != null) {
        convListFragment.getAnimatedAdapter().onSaveInstanceState(outState);
    }
    // If there is a dialog being shown, save the state so we can create a listener for it.
    if (mDialogAction != -1) {
        outState.putInt(SAVED_ACTION, mDialogAction);
        outState.putBoolean(SAVED_ACTION_FROM_SELECTED, mDialogFromSelectedSet);
    }
    if (mDetachedConvUri != null) {
        outState.putParcelable(SAVED_DETACHED_CONV_URI, mDetachedConvUri);
    }

    outState.putParcelable(SAVED_HIERARCHICAL_FOLDER, mFolderListFolder);
    mSafeToModifyFragments = false;

    outState.putParcelable(SAVED_INBOX_KEY, mInbox);

    outState.putBundle(SAVED_CONVERSATION_LIST_SCROLL_POSITIONS, mConversationListScrollPositions);
}

From source file:com.android.mail.ui.AbstractActivityController.java

@Override
public void onSaveInstanceState(Bundle outState) {
    mViewMode.handleSaveInstanceState(outState);
    if (mAccount != null) {
        outState.putParcelable(SAVED_ACCOUNT, mAccount);
    }/*from   www.jav  a2  s . c o  m*/
    if (mFolder != null) {
        outState.putParcelable(SAVED_FOLDER, mFolder);
    }
    // If this is a search activity, let's store the search query term as well.
    if (ConversationListContext.isSearchResult(mConvListContext)) {
        outState.putString(SAVED_QUERY, mConvListContext.searchQuery);
    }
    if (mCurrentConversation != null && mViewMode.isConversationMode()) {
        outState.putParcelable(SAVED_CONVERSATION, mCurrentConversation);
    }
    if (!mCheckedSet.isEmpty()) {
        outState.putParcelable(SAVED_SELECTED_SET, mCheckedSet);
    }
    if (mToastBar.getVisibility() == View.VISIBLE) {
        outState.putParcelable(SAVED_TOAST_BAR_OP, mToastBar.getOperation());
    }
    final ConversationListFragment convListFragment = getConversationListFragment();
    if (convListFragment != null) {
        convListFragment.getAnimatedAdapter().onSaveInstanceState(outState);
    }
    // If there is a dialog being shown, save the state so we can create a listener for it.
    if (mDialogAction != -1) {
        outState.putInt(SAVED_ACTION, mDialogAction);
        outState.putBoolean(SAVED_ACTION_FROM_SELECTED, mDialogFromSelectedSet);
    }
    if (mDetachedConvUri != null) {
        outState.putParcelable(SAVED_DETACHED_CONV_URI, mDetachedConvUri);
    }

    outState.putParcelable(SAVED_HIERARCHICAL_FOLDER, mFolderListFolder);
    mSafeToModifyFragments = false;

    outState.putParcelable(SAVED_INBOX_KEY, mInbox);

    outState.putBundle(SAVED_CONVERSATION_LIST_SCROLL_POSITIONS, mConversationListScrollPositions);

    mSearchViewController.saveState(outState);
}