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:android.app.Activity.java

/**
 * Save the state of any managed dialogs.
 *
 * @param outState place to store the saved state.
 *///from  w  w w  .j  a  va 2  s. c om
private void saveManagedDialogs(Bundle outState) {
    if (mManagedDialogs == null) {
        return;
    }

    final int numDialogs = mManagedDialogs.size();
    if (numDialogs == 0) {
        return;
    }

    Bundle dialogState = new Bundle();

    int[] ids = new int[mManagedDialogs.size()];

    // save each dialog's bundle, gather the ids
    for (int i = 0; i < numDialogs; i++) {
        final int key = mManagedDialogs.keyAt(i);
        ids[i] = key;
        final ManagedDialog md = mManagedDialogs.valueAt(i);
        dialogState.putBundle(savedDialogKeyFor(key), md.mDialog.onSaveInstanceState());
        if (md.mArgs != null) {
            dialogState.putBundle(savedDialogArgsKeyFor(key), md.mArgs);
        }
    }

    dialogState.putIntArray(SAVED_DIALOG_IDS_KEY, ids);
    outState.putBundle(SAVED_DIALOGS_TAG, dialogState);
}

From source file:android.app.Activity.java

/**
 * Migrate the application to other device.
 * This method is called by the Android system.
 *
 * @hide/*  www.java2 s  .c o  m*/
 * @param savedInstanceState A state the application needs to restore.
 * @return true if migration successed.
 */
private boolean systemMigrate(Bundle savedInstanceState) {
    boolean result = true;
    String cName;
    String pName;

    if (savedInstanceState == null)
        savedInstanceState = new Bundle();

    /* store Intent object this Activity has and requestCode for next Activity */
    savedInstanceState.putParcelable("MIGRATED_INTENT", getIntent());
    savedInstanceState.putInt("MIGRATED REQUEST CODE", currentCode);
    savedInstanceState.putBundle("MIGRATED REQUEST OPTIONS", currentOption);
    currentCode = -1;
    currentOption = null;

    if (mMigrator == null) {
        mMigrator = IMigratorService.Stub.asInterface(ServiceManager.getService("Migrator"));
    }

    pName = getPackageName();
    cName = mComponent.getClassName();

    try {
        /* mStartedActivity is true if this Activity calls startActivityForResult().
         * This means the next Activity exists. */
        result = mMigrator.migrate(savedInstanceState, pName, cName, mStartedActivity);
        mStartedActivity = false;
    } catch (RemoteException e) {
        Log.w("MIGRATOR", "Migrate failed");
        result = false;
        e.printStackTrace();
    }

    return result;
}

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

@Override
protected void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    final Bundle inner = new Bundle();
    saveState(inner);/*from  w ww  . j av  a  2  s . com*/
    state.putBundle(KEY_INNER_SAVED_STATE, inner);
    //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_S
    //AM: peng-zhang 2015-04-03 EMAIL BUGFIX_968060 MOD_S
    if (null != mBcc) {
        String bcc_save = mBcc.getText().toString();
        boolean bcc_changed = mBcc.getText().toString().contains(mAccount.getEmailAddress());
        state.putString("BCC_SAVE", bcc_save);
        state.putBoolean("BCC_CHANGED", bcc_changed);
    }
    // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_S
    state.putInt(KEY_PRIORITY_SAVED_STATE, mPriorityFlag);
    // TS: junwei-xu 2015-06-30 EMAIL BUGFIX-1030195 ADD_E
    // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_S
    state.putBoolean(KEY_SAVED_STATE_TEXT_CHANGED, mTextChanged);
    state.putBoolean(KEY_SAVED_STATE_ATTACHMENT_CHANGED, mAttachmentsChanged);
    state.putBoolean(KEY_SAVED_STATE_REPLY_FROM_CHANGED, mReplyFromChanged);
    state.putBoolean(KEY_SAVED_STATE_PRIORITY_CHANGED, mProrityChanged);
    // TS: junwei-xu 2015-07-17 EMAIL BUGFIX-1029180 ADD_E
    //AM: peng-zhang 2015-04-03 EMAIL BUGFIX_968060 MOD_E
    //AM: peng-zhang 2015-02-27 EMAIL BUGFIX_955421 MOD_E
    //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_S
    state.putBoolean(KEY_SAVED_STATE_ATTLARGEWARNING_CHANGED, attLargeWarning);
    //TS: yanhua.chen 2015-7-29 EMAIL BUGFIX_1053132 ADD_E
    //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_S
    //state.putBoolean(KEY_SAVED_STATE_ISCLICKICON_CHANGED, mIsClickIcon);//[BUGFIX]-MOD by SCDTABLET.shujing.jin@tcl.com,05/06/2016,2013535
    state.putBoolean(KEY_SAVED_STATE_CHANGEACCOUNT_CHANGED, mChangeAccount);
    state.putBoolean(KEY_SAVED_STATE_EDITDRAFT_CHANGED, mEditDraft);
    //TS: yanhua.chen 2015-9-1 EMAIL CD_551912 ADD_E
}

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

private Intent createAddContactIntent(RecipientEditTextView textview) {
    //TS: junwei-xu 2016-03-01 EMAIL BUGFIX-1612750 ADD_S
    //Note: different intent for different platform.
    Intent intent = new Intent();
    String platform = PLFUtils.getString(this, "feature_email_platform");
    if (platform.equals(PLATFORM_QUALCOMM)) {
        intent.setAction(ACTION_MULTI_PICK_EMAIL_QUALCOMM);
        intent.setData(Contacts.CONTENT_URI);
    } else if (platform.equals(PLATFORM_MTK)) {
        intent.setAction(ACTION_MULTI_PICK_EMAIL_MTK);
        intent.setType(ContactsContract.CommonDataKinds.Email.CONTENT_TYPE);
    }//from w ww .j  av a2  s . c o  m
    //TS: junwei-xu 2016-03-01 EMAIL BUGFIX-1612750 ADD_E

    // We have to wait for the constructing complete.
    com.tct.emailcommon.mail.Address[] addresses = getAddressesIgnoreValid(textview);
    int addressCount = addresses.length;

    if (addressCount > 0) {
        Bundle bundle = new Bundle();
        Bundle mChoiceSet = new Bundle();
        com.tct.emailcommon.mail.Address address;
        for (int i = 0; i < addressCount; i++) {
            address = addresses[i];
            //[BUGFIX]-Mod-BEGIN by TSCD.chao zhang,05/29/2014,PR 682725,[Email]Can't add mail address from contact option.
            //fix Email address change to invalid when replay mail.
            String name = address.getPersonal();
            if (name != null && !name.equals(address.getAddress())) {
                if (name.matches(".*[\\(\\)<>@,;:\\\\\".\\[\\]].*")) {
                    name = com.tct.emailcommon.mail.Address.ensureQuotedString(name);
                }
            }
            mChoiceSet.putStringArray(String.valueOf(i), new String[] { name, address.getAddress() });
            //[BUGFIX]-Mod-END by TSCD.chao zhang
        }
        bundle.putBundle(EXTRA_PICK_EMAIL_BUNDLE, mChoiceSet);
        intent.putExtras(bundle);
    }
    return intent;
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
    /// TCT: save global search tag, for it may be lost after rotated devices
    outState.putBoolean(SAVED_GLOBAL_SEARCH, mGlobalSearch);
    //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S
    // save the check status for star toggle
    outState.putBoolean(BUNDLE_CHECK_STATUS_KEY, mCheckStatus);
    //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E
    mViewMode.handleSaveInstanceState(outState);
    if (mAccount != null) {
        outState.putParcelable(SAVED_ACCOUNT, mAccount);
    }//from  w  w w  .  java2 s  . c  om
    if (mFolder != null) {
        outState.putParcelable(SAVED_FOLDER, mFolder);
    }
    // TCT: If this is a search activity, let's store the search context
    if (mConvListContext != null) {
        //            outState.putString(SAVED_QUERY, mConvListContext.searchQuery);
        outState.putParcelable(SAVED_LOCAL_SEARCH, mConvListContext.toBundle());
    }
    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());
        //TS: qing.liang 2015-03-10 EMAIL BUGFIX_-941849 ADD_S
        if (mUndoConversation != null) {
            outState.putParcelable(SAVED_UNDO_CONVERSATION, mUndoConversation);
        }
        if (mUndoAction != -1) {
            outState.putInt(SAVED_UNDO_ACTION, mUndoAction);
        }
        //TS: qing.liang 2015-03-10 EMAIL BUGFIX_-941849 ADD_E
        // TS: zheng.zou 2015-09-01 EMAIL BUGFIX-552138 ADD_S
        if (mSavedDraftMsgId != -1) {
            outState.putLong(SAVED_DRAFT_MSG_ID, mSavedDraftMsgId);
        }
        // TS: zheng.zou 2015-09-01 EMAIL BUGFIX-552138 ADD_E
    }
    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);
}