Example usage for android.os Bundle putParcelable

List of usage examples for android.os Bundle putParcelable

Introduction

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

Prototype

public void putParcelable(@Nullable String key, @Nullable Parcelable value) 

Source Link

Document

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

Usage

From source file:com.android.contacts.ContactSaveService.java

/**
 * Creates an intent that can be sent to this service to create a new raw contact
 * using data presented as a set of ContentValues.
 * This variant is more convenient to use when there is only one photo that can
 * possibly be updated, as in the Contact Details screen.
 * @param rawContactId identifies a writable raw-contact whose photo is to be updated.
 * @param updatedPhotoPath denotes a temporary file containing the contact's new photo.
 *//*from   w w w. jav a 2  s  .  c o  m*/
public static Intent createSaveContactIntent(Context context, RawContactDeltaList state,
        String saveModeExtraKey, int saveMode, boolean isProfile, Class<? extends Activity> callbackActivity,
        String callbackAction, long rawContactId, Uri updatedPhotoPath) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(String.valueOf(rawContactId), updatedPhotoPath);
    return createSaveContactIntent(context, state, saveModeExtraKey, saveMode, isProfile, callbackActivity,
            callbackAction, bundle, /* joinContactIdExtraKey */ null, /* joinContactId */ null);
}

From source file:androidx.media.MediaSession2StubImplBase.java

void notifyPlaybackSpeedChanged(final float speed) {
    notifyAll(new Session2Runnable() {
        @Override/* www  .  ja  v  a 2  s .  c o  m*/
        public void run(ControllerInfo controller) throws RemoteException {
            Bundle bundle = new Bundle();
            bundle.putParcelable(ARGUMENT_PLAYBACK_STATE_COMPAT, mSession.getPlaybackStateCompat());
            controller.getControllerBinder().onEvent(SESSION_EVENT_ON_PLAYBACK_SPEED_CHANGED, bundle);
        }
    });
}

From source file:com.buddi.client.dfu.DfuActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (resultCode != RESULT_OK)
        return;/*from  w  ww . jav a  2 s .  c o  m*/

    switch (requestCode) {
    case SELECT_FILE_REQ:
        // clear previous data
        mFileType = mFileTypeTmp;
        mFilePath = null;
        mFileStreamUri = null;

        // and read new one
        final Uri uri = data.getData();
        /*
         * The URI returned from application may be in 'file' or 'content' schema.
         * 'File' schema allows us to create a File object and read details from if directly.
         * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader.
         */
        if (uri.getScheme().equals("file")) {
            // the direct path to the file has been returned
            final String path = uri.getPath();
            final File file = new File(path);
            mFilePath = path;

            updateFileInfo(file.getName(), file.length(), mFileType);
        } else if (uri.getScheme().equals("content")) {
            // an Uri has been returned
            mFileStreamUri = uri;
            // if application returned Uri for streaming, let's us it. Does it works?
            // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox?
            final Bundle extras = data.getExtras();
            if (extras != null && extras.containsKey(Intent.EXTRA_STREAM))
                mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM);

            // file name and size must be obtained from Content Provider
            final Bundle bundle = new Bundle();
            bundle.putParcelable(EXTRA_URI, uri);
            //getSupportLoaderManager().restartLoader(0, bundle, this);
            getLoaderManager().restartLoader(0, bundle, this);
        }
        break;
    default:
        break;
    }
}

From source file:com.nextgis.firereporter.GetFiresService.java

public void onNewNotifictation(long subscriptionID, ScanexNotificationItem item) {
    String sAdds = item.GetPlace().equals("null") ? item.GetType() : item.GetPlace();
    onNotify(3, item.GetShortCoordinates() + "/" + sAdds + "/" + item.GetDateAsString());

    if (mScanexReceiver == null)
        return;//from  ww w.  jav  a  2  s.  c  o m
    Bundle b = new Bundle();
    b.putLong(SUBSCRIPTION_ID, subscriptionID);
    b.putLong(NOTIFICATION_ID, item.GetId());
    b.putInt(TYPE, SCANEX_NOTIFICATION);
    b.putParcelable(ITEM, item);
    mScanexReceiver.send(SERVICE_SCANEXDATA, b);

    mbHasChanges = true;
}

From source file:bottombar.BottomBar.java

@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = saveState();
    bundle.putParcelable("superstate", super.onSaveInstanceState());
    return bundle;
}

From source file:com.sim2dial.dialer.ChatFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    outState.putString("fileToUploadPath", fileToUploadPath);
    outState.putParcelable("imageToUpload", imageToUpload);
    super.onSaveInstanceState(outState);
}

From source file:com.android.browser.BookmarksPageCallbacks.java

private void editBookmark(BrowserBookmarksAdapter adapter, int position) {
    Intent intent = new Intent(getActivity(), AddBookmarkPage.class);
    Cursor cursor = adapter.getItem(position);
    Bundle item = new Bundle();
    item.putString(BrowserContract.Bookmarks.TITLE, cursor.getString(BookmarksLoader.COLUMN_INDEX_TITLE));
    item.putString(BrowserContract.Bookmarks.URL, cursor.getString(BookmarksLoader.COLUMN_INDEX_URL));
    byte[] data = cursor.getBlob(BookmarksLoader.COLUMN_INDEX_FAVICON);
    if (data != null) {
        item.putParcelable(BrowserContract.Bookmarks.FAVICON,
                BitmapFactory.decodeByteArray(data, 0, data.length));
    }/*from   w  ww. j a  v a  2  s .  c om*/
    item.putLong(BrowserContract.Bookmarks._ID, cursor.getLong(BookmarksLoader.COLUMN_INDEX_ID));
    item.putLong(BrowserContract.Bookmarks.PARENT, cursor.getLong(BookmarksLoader.COLUMN_INDEX_PARENT));
    intent.putExtra(AddBookmarkPage.EXTRA_EDIT_BOOKMARK, item);
    intent.putExtra(AddBookmarkPage.EXTRA_IS_FOLDER,
            cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) == 1);
    startActivity(intent);
}

From source file:com.github.chenxiaolong.dualbootpatcher.switcher.InAppFlashingFragment.java

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

    outState.putParcelableArrayList(EXTRA_PENDING_ACTIONS, mPendingActions);

    outState.putParcelable(EXTRA_SELECTED_URI, mSelectedUri);
    outState.putString(EXTRA_SELECTED_URI_FILE_NAME, mSelectedUriFileName);
    outState.putParcelable(EXTRA_SELECTED_BACKUP_DIR_URI, mSelectedBackupDirUri);
    outState.putString(EXTRA_SELECTED_BACKUP_NAME, mSelectedBackupName);
    outState.putStringArray(EXTRA_SELECTED_BACKUP_TARGETS, mSelectedBackupTargets);
    outState.putString(EXTRA_SELECTED_ROM_ID, mSelectedRomId);
    outState.putString(EXTRA_ZIP_ROM_ID, mZipRomId);
    outState.putSerializable(EXTRA_ADD_TYPE, mAddType);
    outState.putInt(EXTRA_TASK_ID_VERIFY_ZIP, mTaskIdVerifyZip);
    outState.putBoolean(EXTRA_QUERYING_METADATA, mQueryingMetadata);
}

From source file:co.ceryle.segmentedbutton.SegmentedButtonGroup.java

@Override
public Parcelable onSaveInstanceState() {
    Bundle bundle = new Bundle();
    bundle.putParcelable("state", super.onSaveInstanceState());
    bundle.putInt("position", position);
    return bundle;
}

From source file:com.android.dialer.voicemail.VoicemailPlaybackPresenter.java

/**
 * Must be invoked when the parent Activity is saving it state.
 *//*from  w w w  .j av  a  2 s . c o  m*/
public void onSaveInstanceState(Bundle outState) {
    if (mView != null) {
        outState.putParcelable(VOICEMAIL_URI_KEY, mVoicemailUri);
        outState.putBoolean(IS_PREPARED_KEY, mIsPrepared);
        outState.putInt(CLIP_POSITION_KEY, mView.getDesiredClipPosition());
        outState.putBoolean(IS_PLAYING_STATE_KEY, mIsPlaying);
        outState.putBoolean(IS_SPEAKERPHONE_ON_KEY, mIsSpeakerphoneOn);
    }
}