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:org.deviceconnect.android.deviceplugin.host.HostDeviceService.java

/**
 * ????????./*www.ja va 2s  .com*/
 * 
 * @param sensorEvent .
 */
public void onSensorChanged(final SensorEvent sensorEvent) {
    if (sensorEvent.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {

        mAccellX = sensorEvent.values[0];
        mAccellY = sensorEvent.values[1];
        mAccellZ = sensorEvent.values[2];

        Bundle orientation = new Bundle();
        Bundle a1 = new Bundle();
        a1.putDouble(DeviceOrientationProfile.PARAM_X, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Y, 0.0);
        a1.putDouble(DeviceOrientationProfile.PARAM_Z, 0.0);
        Bundle a2 = new Bundle();
        a2.putDouble(DeviceOrientationProfile.PARAM_X, mAccellX);
        a2.putDouble(DeviceOrientationProfile.PARAM_Y, mAccellY);
        a2.putDouble(DeviceOrientationProfile.PARAM_Z, mAccellZ);
        Bundle r = new Bundle();
        r.putDouble(DeviceOrientationProfile.PARAM_ALPHA, mGyroX);
        r.putDouble(DeviceOrientationProfile.PARAM_BETA, mGyroY);
        r.putDouble(DeviceOrientationProfile.PARAM_GAMMA, mGyroZ);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION, a1);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ACCELERATION_INCLUDING_GRAVITY, a2);
        orientation.putBundle(DeviceOrientationProfile.PARAM_ROTATION_RATE, r);
        orientation.putLong(DeviceOrientationProfile.PARAM_INTERVAL, 0);
        DeviceOrientationProfile.setInterval(orientation, INTERVAL_TIME);

        List<Event> events = EventManager.INSTANCE.getEventList(mDeviceId,
                DeviceOrientationProfile.PROFILE_NAME, null,
                DeviceOrientationProfile.ATTRIBUTE_ON_DEVICE_ORIENTATION);

        for (int i = 0; i < events.size(); i++) {
            Event event = events.get(i);
            Intent intent = EventManager.createEventMessage(event);

            intent.putExtra(DeviceOrientationProfile.PARAM_ORIENTATION, orientation);
            getContext().sendBroadcast(intent);
        }

    } else if (sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE) {
        mGyroX = sensorEvent.values[0];
        mGyroY = sensorEvent.values[1];
        mGyroZ = sensorEvent.values[2];
    }
}

From source file:saphion.fragments.alarm.AlarmFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);

    outState.putLongArray(KEY_EXPANDED_IDS, mAdapter.getExpandedArray());
    outState.putLongArray(KEY_REPEAT_CHECKED_IDS, mAdapter.getRepeatArray());
    outState.putLongArray(KEY_SELECTED_ALARMS, mAdapter.getSelectedAlarmsArray());
    outState.putBundle(KEY_RINGTONE_TITLE_CACHE, mRingtoneTitleCache);
    outState.putParcelable(KEY_DELETED_ALARM, mDeletedAlarm);
    outState.putBoolean(KEY_UNDO_SHOWING, mUndoShowing);
    outState.putBundle(KEY_PREVIOUS_DAY_MAP, mAdapter.getPreviousDaysOfWeekMap());
    outState.putParcelable(KEY_SELECTED_ALARM, mSelectedAlarm);
}

From source file:de.sourcestream.movieDB.controller.TVDetails.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *//*  w w  w. j a  va 2s. c o  m*/
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null && save.getInt("timeOut") == 1)
        save = null;
    save = null;

    if (save != null) {
        if (tvDetailsCast != null)
            save.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson());
        outState.putBundle("save", save);
        if (addToBackStack) {
            activity.addTvDetailsBundle(save);
            addToBackStack = false;
        }
    } else {
        Bundle send = new Bundle();
        send.putInt("currentId", currentId);
        if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) {
            timeOut = 1;
            request.cancel(true);
        }
        send.putInt("timeOut", timeOut);
        send.putString("title", title);
        if (timeOut == 0) {
            // HomePage
            send.putInt("homeIconCheck", homeIconCheck);
            if (homeIconCheck == 0)
                send.putString("homepage", homeIconUrl);

            // Gallery icon
            send.putInt("galleryIconCheck", galleryIconCheck);
            if (galleryIconCheck == 0)
                send.putStringArrayList("galleryList", galleryList);

            // More icon
            send.putInt("moreIconCheck", moreIconCheck);
            // used to pass the data to the castList view
            send.putParcelableArrayList("seasonList", seasonList);

        }

        // TV details info begins here
        if (tvDetailsInfo != null) {
            // Backdrop path
            send.putInt("backDropCheck", tvDetailsInfo.getBackDropCheck());
            if (tvDetailsInfo.getBackDropCheck() == 0 && tvDetailsInfo.getBackDropPath().getTag() != null)
                send.putString("backDropUrl", tvDetailsInfo.getBackDropPath().getTag().toString());

            // Poster path url
            if (tvDetailsInfo.getPosterPath().getTag() != null)
                send.putString("posterPathURL", tvDetailsInfo.getPosterPath().getTag().toString());

            // Rating
            send.putFloat("rating", tvDetailsInfo.getRatingBar().getRating());
            send.putString("voteCount", tvDetailsInfo.getVoteCount().getText().toString());

            // Title
            send.putString("titleText", tvDetailsInfo.getTitle().getText().toString());

            // Status
            send.putString("status", tvDetailsInfo.getStatusText().getText().toString());

            // Type
            send.putString("typeText", tvDetailsInfo.getTypeText().getText().toString());

            // Episode runtime
            send.putString("episodeRuntime", tvDetailsInfo.getEpisodeRuntime().getText().toString());

            // Number of episodes
            send.putString("numberOfEpisodesText",
                    tvDetailsInfo.getNumberOfEpisodesText().getText().toString());

            // Number of seasons
            send.putString("numberOfSeasonsText", tvDetailsInfo.getNumberOfSeasonsText().getText().toString());

            // First air date
            send.putString("firstAirDateText", tvDetailsInfo.getFirstAirDateText().getText().toString());

            // Last air date
            send.putString("lastAirDateText", tvDetailsInfo.getLastAirDateText().getText().toString());

            // Genres
            send.putString("genres", tvDetailsInfo.getGenres().getText().toString());

            // Production countries
            send.putString("productionCountries", tvDetailsInfo.getCountries().getText().toString());

            // Production companies
            send.putString("productionCompanies", tvDetailsInfo.getCompanies().getText().toString());

            // Similar list
            if (tvDetailsInfo.getSimilarList() != null && tvDetailsInfo.getSimilarList().size() > 0)
                send.putParcelableArrayList("similarList", tvDetailsInfo.getSimilarList());

        }
        // TV details info ends here

        // TV details cast starts here
        if (tvDetailsCast != null) {
            send.putParcelableArrayList("castList", castList);
            send.putInt("lastVisitedPerson", tvDetailsCast.getLastVisitedPerson());
        }
        // TV details cast ends here

        if (tvDetailsOverview != null)
            send.putString("overview", tvDetailsOverview.getOverview().getText().toString());

        outState.putBundle("save", send);
        save = send;
        if (addToBackStack) {
            activity.addTvDetailsBundle(send);
            addToBackStack = false;
        }
    }

}

From source file:de.sourcestream.movieDB.controller.MovieDetails.java

/**
 * Called to ask the fragment to save its current dynamic state,
 * so it can later be reconstructed in a new instance of its process is restarted.
 *
 * @param outState Bundle in which to place your saved state.
 *///from   w  ww.  j a v a2s .  c  o m
@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    // Used to avoid bug where we add item in the back stack
    // and if we change orientation twice the item from the back stack has null values
    if (save != null && save.getInt("timeOut") == 1)
        save = null;

    if (save != null) {
        if (movieDetailsCast != null)
            save.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson());
        outState.putBundle("save", save);
        if (addToBackStack) {
            activity.addMovieDetailsBundle(save);
            addToBackStack = false;
        }
    } else {
        Bundle send = new Bundle();
        send.putInt("currentId", currentId);
        if (request != null && request.getStatus() == AsyncTask.Status.RUNNING) {
            timeOut = 1;
            request.cancel(true);
        }
        send.putInt("timeOut", timeOut);
        send.putString("title", title);
        if (timeOut == 0) {
            // HomePage
            send.putInt("homeIconCheck", homeIconCheck);
            if (homeIconCheck == 0)
                send.putString("homepage", homeIconUrl);

            // Gallery icon
            send.putInt("galleryIconCheck", galleryIconCheck);
            if (galleryIconCheck == 0)
                send.putStringArrayList("galleryList", galleryList);

            // Trailer icon
            send.putInt("trailerIconCheck", trailerIconCheck);
            if (trailerIconCheck == 0)
                send.putStringArrayList("trailerList", trailerList);

            // More icon
            send.putInt("moreIconCheck", moreIconCheck);

            // Movie details info begins here
            if (movieDetailsInfo != null) {
                // Backdrop path
                send.putInt("backDropCheck", movieDetailsInfo.getBackDropCheck());
                if (movieDetailsInfo.getBackDropCheck() == 0
                        && movieDetailsInfo.getBackDropPath().getTag() != null)
                    send.putString("backDropUrl", movieDetailsInfo.getBackDropPath().getTag().toString());

                // Poster path url
                if (movieDetailsInfo.getPosterPath().getTag() != null)
                    send.putString("posterPathURL", movieDetailsInfo.getPosterPath().getTag().toString());

                // Rating
                send.putFloat("rating", movieDetailsInfo.getRatingBar().getRating());
                send.putString("voteCount", movieDetailsInfo.getVoteCount().getText().toString());

                // Title
                send.putString("titleText", movieDetailsInfo.getTitleText().getText().toString());

                // Release date
                send.putString("releaseDate", movieDetailsInfo.getReleaseDate().getText().toString());

                // Status
                send.putString("status", movieDetailsInfo.getStatusText().getText().toString());

                // Tag line
                send.putString("tagline", movieDetailsInfo.getTagline().getText().toString());

                // RunTime
                send.putString("runTime", movieDetailsInfo.getRuntime().getText().toString());

                // Genres
                send.putString("genres", movieDetailsInfo.getGenres().getText().toString());

                // Production countries
                send.putString("productionCountries", movieDetailsInfo.getCountries().getText().toString());

                // Production companies
                send.putString("productionCompanies", movieDetailsInfo.getCompanies().getText().toString());

                // Similar list
                if (movieDetailsInfo.getSimilarList() != null && movieDetailsInfo.getSimilarList().size() > 0)
                    send.putParcelableArrayList("similarList", movieDetailsInfo.getSimilarList());
            }
            // Movie details info ends here

            // Movie details cast starts here
            if (movieDetailsCast != null) {
                send.putParcelableArrayList("castList", castList);
                send.putInt("lastVisitedPerson", movieDetailsCast.getLastVisitedPerson());
            }
            // Movie details cast ends here

            // Overview
            if (movieDetailsOverview != null)
                send.putString("overview", movieDetailsOverview.getOverview().getText().toString());

        }

        outState.putBundle("save", send);
        save = send;
        if (addToBackStack) {
            activity.addMovieDetailsBundle(send);
            addToBackStack = false;
        }
    }

}

From source file:net.exclaimindustries.geohashdroid.activities.CentralMap.java

@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);

    // Also, keep the latest Info around.
    outState.putParcelable(STATE_INFO, mCurrentInfo);

    // Keep the various flags, too.
    outState.putBoolean(STATE_WAS_ALREADY_ZOOMED, mAlreadyDidInitialZoom);
    outState.putBoolean(STATE_WAS_SELECT_A_GRATICULE, mSelectAGraticule);
    outState.putBoolean(STATE_WAS_GLOBALHASH, mGlobalhash);
    outState.putBoolean(STATE_WAS_RESOLVING_CONNECTION_ERROR, mResolvingError);
    outState.putBoolean(STATE_WERE_PERMISSIONS_DENIED, mPermissionsDenied);

    // And some additional data.
    outState.putParcelable(STATE_LAST_GRATICULE, mLastGraticule);
    outState.putSerializable(STATE_LAST_CALENDAR, mLastCalendar);

    // Aaaaaaaand the map type.
    if (mMap != null)
        outState.putInt(STATE_MAP_TYPE, mMap.getMapType());

    // Also, shut down the current mode.  We'll rebuild it later.  Also, if
    // init isn't complete yet, don't update the state.
    if (mCurrentMode != null && mCurrentMode.isInitComplete()) {
        mLastModeBundle = new Bundle();
        mCurrentMode.onSaveInstanceState(mLastModeBundle);
    }/*from ww  w. ja  v  a  2s.c o  m*/

    outState.putBundle(STATE_LAST_MODE_BUNDLE, mLastModeBundle);
}

From source file:com.google.blockly.android.control.BlocklyController.java

/**
 * Saves a snapshot of current workspace contents to a temporary cache file, and saves the
 * filename to the instance state bundle.
 * @param mSavedInstanceState/*from w ww  . j  a va 2s .  c  o  m*/
 * @return
 */
public boolean onSaveSnapshot(Bundle mSavedInstanceState) {
    Bundle blocklyState = new Bundle();

    // First attempt to save the workspace to a file.
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        mWorkspace.serializeToXml(out);
        blocklyState.putByteArray(SERIALIZED_WORKSPACE_KEY, out.toByteArray());
    } catch (BlocklySerializerException e) {
        Log.w(TAG, "Error serializing workspace.", e);
        return false;
    } finally {
        try {
            out.close();
        } catch (IOException e) {
            // Ignore.
        }
    }

    // TODO(#58): Save the rest of the state.

    // Success!
    mSavedInstanceState.putBundle(SNAPSHOT_BUNDLE_KEY, blocklyState);
    return true;
}

From source file:de.mrapp.android.preference.activity.PreferenceActivity.java

@CallSuper
@Override//  w w w  . j  a v a 2  s  . com
protected void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(CURRENT_BUNDLE_EXTRA, currentBundle);
    outState.putCharSequence(CURRENT_TITLE_EXTRA, currentTitle);
    outState.putCharSequence(CURRENT_SHORT_TITLE_EXTRA, currentShortTitle);
    outState.putParcelable(CURRENT_PREFERENCE_HEADER_EXTRA, currentHeader);
    outState.putParcelableArrayList(PREFERENCE_HEADERS_EXTRA, getListAdapter().getAllItems());

    if (preferenceScreenFragment != null && preferenceScreenFragment.isAdded()) {
        getFragmentManager().putFragment(outState, PREFERENCE_SCREEN_FRAGMENT_EXTRA, preferenceScreenFragment);
    }
}

From source file:org.opendatakit.survey.activities.MainMenuActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // TODO Auto-generated method stub
    super.onSaveInstanceState(outState);

    if (dispatchStringWaitingForData != null) {
        outState.putString(DISPATCH_STRING_WAITING_FOR_DATA, dispatchStringWaitingForData);
    }//from w  w  w  . ja  va2s.  c  om
    if (actionWaitingForData != null) {
        outState.putString(ACTION_WAITING_FOR_DATA, actionWaitingForData);
    }
    outState.putString(CURRENT_FRAGMENT, currentFragment.name());

    if (getCurrentForm() != null) {
        outState.putString(FORM_URI, getCurrentForm().formUri.toString());
    }
    if (getInstanceId() != null) {
        outState.putString(INSTANCE_ID, getInstanceId());
    }
    if (getUploadTableId() != null) {
        outState.putString(UPLOAD_TABLE_ID, getUploadTableId());
    }
    if (getScreenPath() != null) {
        outState.putString(SCREEN_PATH, getScreenPath());
    }
    if (getControllerState() != null) {
        outState.putString(CONTROLLER_STATE, getControllerState());
    }
    if (getAuxillaryHash() != null) {
        outState.putString(AUXILLARY_HASH, getAuxillaryHash());
    }
    if (getAppName() != null) {
        outState.putString(IntentConsts.INTENT_KEY_APP_NAME, getAppName());
    }
    outState.putBundle(SESSION_VARIABLES, sessionVariables);

    outState.putParcelableArrayList(SECTION_STATE_SCREEN_HISTORY, sectionStateScreenHistory);

    if (!queuedActions.isEmpty()) {
        String[] actionOutcomesArray = new String[queuedActions.size()];
        queuedActions.toArray(actionOutcomesArray);
        outState.putStringArray(QUEUED_ACTIONS, actionOutcomesArray);
    }

    if (!queueResponseJSON.isEmpty()) {
        String[] qra = queueResponseJSON.toArray(new String[queueResponseJSON.size()]);
        outState.putStringArray(RESPONSE_JSON, qra);
    }

    if (mConflictTables != null && !mConflictTables.isEmpty()) {
        outState.putBundle(CONFLICT_TABLES, mConflictTables);
    }

}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

@Override
protected void onSaveInstanceState(Bundle outState) {
    // TODO Auto-generated method stub
    super.onSaveInstanceState(outState);

    if (pageWaitingForData != null) {
        outState.putString(PAGE_WAITING_FOR_DATA, pageWaitingForData);
    }//from   w w w  .j av  a2s . c  om
    if (pathWaitingForData != null) {
        outState.putString(PATH_WAITING_FOR_DATA, pathWaitingForData);
    }
    if (actionWaitingForData != null) {
        outState.putString(ACTION_WAITING_FOR_DATA, actionWaitingForData);
    }
    outState.putString(CURRENT_FRAGMENT, currentFragment.name());

    if (getCurrentForm() != null) {
        outState.putString(FORM_URI, getCurrentForm().formUri.toString());
    }
    if (getInstanceId() != null) {
        outState.putString(INSTANCE_ID, getInstanceId());
    }
    if (getUploadTableId() != null) {
        outState.putString(UPLOAD_TABLE_ID, getUploadTableId());
    }
    if (getScreenPath() != null) {
        outState.putString(SCREEN_PATH, getScreenPath());
    }
    if (getControllerState() != null) {
        outState.putString(CONTROLLER_STATE, getControllerState());
    }
    if (getAuxillaryHash() != null) {
        outState.putString(AUXILLARY_HASH, getAuxillaryHash());
    }
    if (getAppName() != null) {
        outState.putString(APP_NAME, getAppName());
    }
    outState.putBundle(SESSION_VARIABLES, sessionVariables);

    outState.putParcelableArrayList(SECTION_STATE_SCREEN_HISTORY, sectionStateScreenHistory);

    if (mConflictTables != null && !mConflictTables.isEmpty()) {
        outState.putBundle(CONFLICT_TABLES, mConflictTables);
    }

}