List of usage examples for android.os Bundle putBundle
public void putBundle(@Nullable String key, @Nullable Bundle value)
From source file:androidx.media.MediaController2.java
/** * Request that the player start playback for a specific media id. * * @param mediaId The id of the requested media. * @param extras Optional extras that can include extra information about the media item * to be played.//from w ww .j a va 2 s . c o m */ public void playFromMediaId(@NonNull String mediaId, @Nullable Bundle extras) { synchronized (mLock) { if (!mConnected) { Log.w(TAG, "Session isn't active", new IllegalStateException()); return; } Bundle args = new Bundle(); args.putString(ARGUMENT_MEDIA_ID, mediaId); args.putBundle(ARGUMENT_EXTRAS, extras); sendCommand(COMMAND_CODE_SESSION_PLAY_FROM_MEDIA_ID, args); } }
From source file:androidx.media.MediaController2.java
/** * Request that the player prepare playback for a specific media id. In other words, other * sessions can continue to play during the preparation of this session. This method can be * used to speed up the start of the playback. Once the preparation is done, the session * will change its playback state to {@link MediaPlayerBase#PLAYER_STATE_PAUSED}. Afterwards, * {@link #play} can be called to start playback. If the preparation is not needed, * {@link #playFromMediaId} can be directly called without this method. * * @param mediaId The id of the requested media. * @param extras Optional extras that can include extra information about the media item * to be prepared./*from w w w . j a v a 2 s .co m*/ */ public void prepareFromMediaId(@NonNull String mediaId, @Nullable Bundle extras) { synchronized (mLock) { if (!mConnected) { Log.w(TAG, "Session isn't active", new IllegalStateException()); return; } Bundle args = new Bundle(); args.putString(ARGUMENT_MEDIA_ID, mediaId); args.putBundle(ARGUMENT_EXTRAS, extras); sendCommand(COMMAND_CODE_SESSION_PREPARE_FROM_MEDIA_ID, args); } }
From source file:androidx.media.MediaController2.java
/** * Rate the media. This will cause the rating to be set for the current user. * The rating style must follow the user rating style from the session. * You can get the rating style from the session through the * {@link MediaMetadata2#getRating(String)} with the key * {@link MediaMetadata2#METADATA_KEY_USER_RATING}. * <p>/*from w ww .j ava 2s . c o m*/ * If the user rating was {@code null}, the media item does not accept setting user rating. * * @param mediaId The id of the media * @param rating The rating to set */ public void setRating(@NonNull String mediaId, @NonNull Rating2 rating) { synchronized (mLock) { if (!mConnected) { Log.w(TAG, "Session isn't active", new IllegalStateException()); return; } Bundle args = new Bundle(); args.putString(ARGUMENT_MEDIA_ID, mediaId); args.putBundle(ARGUMENT_RATING, rating.toBundle()); sendCommand(COMMAND_CODE_SESSION_SET_RATING, args); } }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); // Save dialog extras. outState.putBundle(EXTRA_DIALOG_EXTRAS, mDialogExtras); // Save list position. final ListView l = getListView(); int topPosition = l.getFirstVisiblePosition(); final View topView = l.getChildAt(0); final int top = (topView == null) ? 0 : topView.getTop(); outState.putInt(EXTRA_TOP_POSITION, topPosition); outState.putInt(EXTRA_TOP, top);/* www . j a va 2 s . c o m*/ }
From source file:androidx.media.MediaController2.java
/** * Sets the playlist./*from www . j av a2 s .com*/ * <p> * Even when the playlist is successfully set, use the playlist returned from * {@link #getPlaylist()} for playlist APIs such as {@link #skipToPlaylistItem(MediaItem2)}. * Otherwise the session in the remote process can't distinguish between media items. * * @param list playlist * @param metadata metadata of the playlist * @see #getPlaylist() * @see ControllerCallback#onPlaylistChanged */ public void setPlaylist(@NonNull List<MediaItem2> list, @Nullable MediaMetadata2 metadata) { if (list == null) { throw new IllegalArgumentException("list shouldn't be null"); } Bundle args = new Bundle(); args.putParcelableArray(ARGUMENT_PLAYLIST, MediaUtils2.toMediaItem2ParcelableArray(list)); args.putBundle(ARGUMENT_PLAYLIST_METADATA, metadata == null ? null : metadata.toBundle()); sendCommand(COMMAND_CODE_PLAYLIST_SET_LIST, args); }
From source file:com.android.deskclock.AlarmClockFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putLong(KEY_EXPANDED_ID, mAdapter.getExpandedId()); 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:com.bangz.smartmute.LocationsMapFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mSavedMarkerExInfos.isEmpty() == false) { mSavedMarkerExInfos.clear();// w ww . java 2 s . c o m } Collection<Marker> newplaces = markerManager.getCollection(MC_ID_NEWPLACE).getMarkers(); for (Marker marker : newplaces) { mSavedMarkerExInfos.add(markerManager.getExtraInfo(marker)); } Collection<Marker> currplace = markerManager.getCollection(MC_ID_CURRPLACE).getMarkers(); for (Marker marker : currplace) { mSavedMarkerExInfos.add(markerManager.getExtraInfo(marker)); } Bundle mybundle = new Bundle(); mybundle.putParcelableArrayList(KEY_STATE_MARKERS, mSavedMarkerExInfos); mybundle.putInt(KEY_STATE_MAPINIT, mapInitState); mybundle.putBoolean(KEY_STATE_LOCATION_UPDATED, bLocationUpdated); mybundle.putInt(KEY_STATE_LOCATION_UPDATE_TYPE, mLocationUpdateType); if (markerSelected != null) { MarkerExInfo meiselected = markerManager.getExtraInfo(markerSelected); mybundle.putParcelable(KEY_STATE_SELECT_MARKER, meiselected); } outState.putBundle(KEY_STATE_MYARGUMENT, mybundle); }
From source file:com.TagFu.facebook.Session.java
/** * Save the Session object into the supplied Bundle. This method is intended to be called from an Activity or * Fragment's onSaveInstanceState method in order to preserve Sessions across Activity lifecycle events. * * @param session the Session to save//from w ww. j ava 2 s . c o m * @param bundle the Bundle to save the Session to */ public static final void saveSession(final Session session, final Bundle bundle) { if ((bundle != null) && (session != null) && !bundle.containsKey(SESSION_BUNDLE_SAVE_KEY)) { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { new ObjectOutputStream(outputStream).writeObject(session); } catch (final IOException e) { throw new FacebookException("Unable to save session.", e); } bundle.putByteArray(SESSION_BUNDLE_SAVE_KEY, outputStream.toByteArray()); bundle.putBundle(AUTH_BUNDLE_SAVE_KEY, session.authorizationBundle); } }
From source file:de.sourcestream.movieDB.controller.CastDetails.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. *///www .ja v a2 s. co 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) { outState.putBundle("save", save); if (addToBackStack) { activity.addCastDetailsBundle(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); // Cast details info begins here if (castDetailsInfo != null) { // Name send.putString("name", castDetailsInfo.getName().getText().toString()); // Poster path url if (castDetailsInfo.getProfilePath().getTag() != null) send.putString("profilePathURL", castDetailsInfo.getProfilePath().getTag().toString()); // Birth info send.putString("birthInfo", castDetailsInfo.getBirthInfo().getText().toString()); // Also known as send.putString("alsoKnownAs", castDetailsInfo.getAlsoKnownAs().getText().toString()); // Known list if (castDetailsInfo.getKnownList() != null && castDetailsInfo.getKnownList().size() > 0) send.putParcelableArrayList("knownList", castDetailsInfo.getKnownList()); } // Cast details info ends here // Credits starts here if (castDetailsCredits != null) send.putParcelableArrayList("moviesList", moviesList); // Credits ends here // Overview if (castDetailsBiography != null) send.putString("biography", castDetailsBiography.getBiography().getText().toString()); } outState.putBundle("save", send); save = send; if (addToBackStack) { activity.addCastDetailsBundle(send); addToBackStack = false; } } }
From source file:com.ichi2.anki.NoteEditor.java
@Override protected void onSaveInstanceState(Bundle savedInstanceState) { Timber.i("Saving instance"); savedInstanceState.putInt("caller", mCaller); savedInstanceState.putBoolean("addFact", mAddNote); savedInstanceState.putLong("did", mCurrentDid); savedInstanceState.putStringArray("tags", mSelectedTags.toArray(new String[mSelectedTags.size()])); Bundle fields = new Bundle(); // Save the content of all the note fields. We use the field's ord as the key to // easily map the fields correctly later. for (FieldEditText e : mEditFields) { fields.putString(Integer.toString(e.getOrd()), e.getText().toString()); }/*from w w w. ja v a 2s .c o m*/ savedInstanceState.putBundle("editFields", fields); super.onSaveInstanceState(savedInstanceState); }