Java Code Examples for android.os.Bundle.putParcelable()

The following are Jave code examples for showing how to use putParcelable() of the android.os.Bundle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitJourney   File: UserProfileActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_user_profile);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    GitHubUserProfileDataEntry entry = getIntent().getParcelableExtra("profile");
    Log.v(TAG, "entry " + entry.getImageUri());
    getSupportActionBar().setTitle(entry.getName());
    getSupportActionBar().setSubtitle(entry.getLocation());
    UserProfileFragment userProfileFragment = UserProfileFragment.newInstance();
    Bundle bundle = new Bundle();
    bundle.putParcelable("entry", entry);
    userProfileFragment.setArguments(bundle);
    getSupportFragmentManager().beginTransaction().replace(R.id.user_profile_fragment, userProfileFragment).commit();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example 2
Project: letv   File: FragmentActivity.java   View Source Code Vote up 6 votes
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Parcelable p = this.mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    if (this.mPendingFragmentActivityResults.size() > 0) {
        outState.putInt(NEXT_CANDIDATE_REQUEST_INDEX_TAG, this.mNextCandidateRequestIndex);
        int[] requestCodes = new int[this.mPendingFragmentActivityResults.size()];
        String[] fragmentWhos = new String[this.mPendingFragmentActivityResults.size()];
        for (int i = 0; i < this.mPendingFragmentActivityResults.size(); i++) {
            requestCodes[i] = this.mPendingFragmentActivityResults.keyAt(i);
            fragmentWhos[i] = (String) this.mPendingFragmentActivityResults.valueAt(i);
        }
        outState.putIntArray(ALLOCATED_REQUEST_INDICIES_TAG, requestCodes);
        outState.putStringArray(REQUEST_FRAGMENT_WHO_TAG, fragmentWhos);
    }
}
 
Example 3
Project: LaunchEnr   File: Launcher.java   View Source Code Vote up 6 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    if (mWorkspace.getChildCount() > 0) {
        outState.putInt(RUNTIME_STATE_CURRENT_SCREEN,
                mWorkspace.getCurrentPageOffsetFromCustomContent());

    }
    super.onSaveInstanceState(outState);

    outState.putInt(RUNTIME_STATE, mState.ordinal());
    // We close any open folders and shortcut containers since they will not be re-opened,
    // and we need to make sure this state is reflected.
    AbstractFloatingView.closeAllOpenViews(this, false);

    if (mPendingRequestArgs != null) {
        outState.putParcelable(RUNTIME_STATE_PENDING_REQUEST_ARGS, mPendingRequestArgs);
    }
    if (mPendingActivityResult != null) {
        outState.putParcelable(RUNTIME_STATE_PENDING_ACTIVITY_RESULT, mPendingActivityResult);
    }

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onSaveInstanceState(outState);
    }
}
 
Example 4
Project: Orin   File: AppShortcutLauncherActivity.java   View Source Code Vote up 5 votes
private void startServiceWithPlaylist(int shuffleMode, Playlist playlist) {
    Intent intent = new Intent(this, MusicService.class);
    intent.setAction(MusicService.ACTION_PLAY_PLAYLIST);

    Bundle bundle = new Bundle();
    bundle.putParcelable(MusicService.INTENT_EXTRA_PLAYLIST, playlist);
    bundle.putInt(MusicService.INTENT_EXTRA_SHUFFLE_MODE, shuffleMode);

    intent.putExtras(bundle);

    startService(intent);
}
 
Example 5
Project: FireFiles   File: DocumentsContract.java   View Source Code Vote up 5 votes
public static Uri createDocument(ContentProviderClient client, Uri parentDocumentUri,
                                 String mimeType, String displayName) throws Exception {
    final Bundle in = new Bundle();
    in.putParcelable(DocumentsContract.EXTRA_URI, parentDocumentUri);
    in.putString(DocumentsContract.Document.COLUMN_MIME_TYPE, mimeType);
    in.putString(DocumentsContract.Document.COLUMN_DISPLAY_NAME, displayName);

    final Bundle out = client.call(METHOD_CREATE_DOCUMENT, null, in);
    return out.getParcelable(DocumentsContract.EXTRA_URI);
}
 
Example 6
Project: boohee_v5.6   File: MediaControllerCompat.java   View Source Code Vote up 5 votes
public void playFromUri(Uri uri, Bundle extras) {
    if (uri == null || Uri.EMPTY.equals(uri)) {
        throw new IllegalArgumentException("You must specify a non-empty Uri for playFromUri.");
    }
    Bundle bundle = new Bundle();
    bundle.putParcelable(MediaSessionCompat.ACTION_ARGUMENT_URI, uri);
    bundle.putParcelable(MediaSessionCompat.ACTION_ARGUMENT_EXTRAS, extras);
    sendCustomAction(MediaSessionCompat.ACTION_PLAY_FROM_URI, bundle);
}
 
Example 7
Project: CouponsTracker   File: CouponRemoteViewsFactory.java   View Source Code Vote up 5 votes
@Override
public RemoteViews getViewAt(int position) {
    if (position == MAX_WIDGET_ROWS_LIMIT) {
        return showWidgetItemViewAll();
    }

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_item_coupon);
    remoteViews.setTextViewText(R.id.text_view_merchant, coupons.get(position).merchant);
    remoteViews.setTextViewText(R.id.text_view_category, coupons.get(position).category);
    remoteViews.setTextViewText(R.id.text_view_valid_until, Utilities.getStringDate(coupons.get(position).validUntil));
    remoteViews.setTextViewText(R.id.text_view_coupon_code, coupons.get(position).couponCode);

    int colorId = R.color.material_orange_900;
    String couponStateText = context.getString(R.string.coupon_state_available);
    if (coupons.get(position).state == 1) {
        colorId = R.color.material_green_700;
        couponStateText = context.getString(R.string.coupon_state_used);
    }
    remoteViews.setTextColor(R.id.text_view_coupon_state, ContextCompat.getColor(context.getApplicationContext(), colorId));
    remoteViews.setTextViewText(R.id.text_view_coupon_state, couponStateText);

    Bundle extras = new Bundle();
    extras.putInt(Constants.COUPON_FRAGMENT_MODE, CouponFragment.Mode.VIEW);
    extras.putParcelable(Constants.COUPON_PARCELABLE, coupons.get(position));
    if (!isTablet) {
        extras.putStringArrayList(Constants.BUNDLE_EXTRA_MERCHANT_SUGGESTIONS, new ArrayList<String>());
        extras.putStringArrayList(Constants.BUNDLE_EXTRA_CATEGORY_SUGGESTIONS, new ArrayList<String>());
    } else {
        extras.putBoolean(Constants.BUNDLE_EXTRA_LOAD_COUPON_FRAGMENT, true);
    }

    Intent fillInIntent = new Intent();
    fillInIntent.putExtras(extras);
    remoteViews.setOnClickFillInIntent(R.id.widget_row, fillInIntent);

    return remoteViews;
}
 
Example 8
Project: okwallet   File: SendCoinsFragment.java   View Source Code Vote up 5 votes
private void saveInstanceState(final Bundle outState) {
    outState.putSerializable("state", state);

    outState.putParcelable("payment_intent", paymentIntent);
    outState.putSerializable("fee_category", feeCategory);
    if (validatedAddress != null)
        outState.putParcelable("validated_address", validatedAddress);

    if (sentTransaction != null)
        outState.putSerializable("sent_transaction_hash", sentTransaction.getHash());
    if (directPaymentAck != null)
        outState.putBoolean("direct_payment_ack", directPaymentAck);
}
 
Example 9
Project: mobile-store   File: ShareChooserDialog.java   View Source Code Vote up 5 votes
public static void createChooser(CoordinatorLayout rootView,
                                 ShareChooserDialog.ShareChooserDialogListener listener,
                                 final AppCompatActivity parent,
                                 final Intent shareIntent,
                                 boolean showNearbyItem) {
    ShareChooserDialog d = new ShareChooserDialog();
    d.setListener(listener);
    Bundle args = new Bundle();
    args.putInt(ARG_WIDTH, rootView.getWidth());
    args.putParcelable(ARG_INTENT, shareIntent);
    args.putBoolean(ARG_SHOW_NEARBY, showNearbyItem);
    d.setArguments(args);
    d.show(parent.getSupportFragmentManager(), "Share");
}
 
Example 10
Project: Inflix   File: BaseDetailsFragment.java   View Source Code Vote up 5 votes
@SuppressWarnings("unchecked")
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putLong(RESOURCE_ID, mResourceId);
    outState.putString(RESOURCE_TITLE, mResourceTitle);
    if (isMovieDetailFragment) {
        outState.putParcelable(DETAILS, mMovieDetail);
    } else {
        outState.putParcelable(DETAILS, mTVShowDetail);
    }
    outState.putParcelableArrayList(SIMILAR, (ArrayList<? extends Parcelable>) mSimilarList);
    outState.putParcelableArrayList(CAST, (ArrayList<? extends Parcelable>) mCastList);
}
 
Example 11
Project: RippleValidatorEditText   File: RippleValidatorEditText.java   View Source Code Vote up 5 votes
@Override protected Parcelable onSaveInstanceState() {
  super.onSaveInstanceState();
  Bundle bundle = new Bundle();
  bundle.putParcelable("superState", super.onSaveInstanceState());
  bundle.putString("editText_title",mEditText.getText().toString());
  return bundle;
}
 
Example 12
Project: Watermark   File: MediaGridFragment.java   View Source Code Vote up 5 votes
public static MediaGridFragment newInstance(Configuration configuration) {
    MediaGridFragment fragment = new MediaGridFragment();
    Bundle bundle = new Bundle();
    bundle.putParcelable(EXTRA_CONFIGURATION, configuration);
    fragment.setArguments(bundle);
    return fragment;
}
 
Example 13
Project: Phoenix-for-VK   File: CreatePhotoAlbumFragment.java   View Source Code Vote up 5 votes
public static Bundle buildArgsForEdit(int aid, @NonNull PhotoAlbum album, @NonNull PhotoAlbumEditor editor) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(EXTRA_EDITOR, editor);
    bundle.putParcelable(Extra.ALBUM, album);
    bundle.putInt(Extra.ACCOUNT_ID, aid);
    return bundle;
}
 
Example 14
Project: Phony-Android   File: PhonyAuthenticator.java   View Source Code Vote up 5 votes
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
    Log.d(TAG, "addAccount: called.");

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
 
Example 15
Project: GitHub   File: ParcelUtils.java   View Source Code Vote up 5 votes
public static Parcel writeToParcel(Parcelable instance, String key) {
    Bundle bundle = new Bundle();
    bundle.putParcelable(key, instance);
    
    Parcel parcel = Parcel.obtain();
    parcel.writeBundle(bundle);
    return parcel;
}
 
Example 16
Project: airgram   File: ColorPicker.java   View Source Code Vote up 5 votes
@Override
protected Parcelable onSaveInstanceState() {
    Bundle state = new Bundle();
    state.putFloatArray("color", colorHSV);
    state.putParcelable("super", super.onSaveInstanceState());
    return state;
}
 
Example 17
Project: redpacketui-open   File: SendSinglePacketFragment.java   View Source Code Vote up 5 votes
public static SendSinglePacketFragment newInstance(RedPacketInfo redPacketInfo) {
    SendSinglePacketFragment fragment = new SendSinglePacketFragment();
    Bundle args = new Bundle();
    args.putParcelable(ARGS_RED_PACKET_INFO, redPacketInfo);
    fragment.setArguments(args);
    return fragment;
}
 
Example 18
Project: garras   File: Bundler.java   View Source Code Vote up 5 votes
public Bundler put(@NonNull String key, Parcelable value) {
    Bundle safeBundle = new Bundle();
    safeBundle.putParcelable(key, value);
    if (isValidBundleSize(safeBundle)) {
        bundle.putParcelable(key, value);
    }
    clearBundle(safeBundle);
    return this;
}
 
Example 19
Project: TrainPonctuality   File: InputArrivalActivity.java   View Source Code Vote up 4 votes
@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putParcelable("currentTravel", currentTravel);
}
 
Example 20
Project: Exoplayer2Radio   File: PlayerActivity.java   View Source Code Vote up 4 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // set content view
    setContentView(R.layout.activity_player);

    // get intent
    Intent intent = getIntent();

    // CASE: show player in phone mode
    if (intent != null && ACTION_SHOW_PLAYER.equals(intent.getAction())) {

        // get station from intent
        Station station;
        if (intent.hasExtra(EXTRA_STATION)) {
            station = intent.getParcelableExtra(EXTRA_STATION);
        } else {
            station = null;
        }

        // get id of station from intent
        int stationID = 0;
        if (intent.hasExtra(EXTRA_STATION_ID)) {
            stationID = intent.getIntExtra(EXTRA_STATION_ID, 0);
        }

        // get playback action from intent (if started from shortcut)
        boolean startPlayback;
        if (intent.hasExtra(EXTRA_PLAYBACK_STATE)) {
            startPlayback = intent.getBooleanExtra(EXTRA_PLAYBACK_STATE, false);

            // enable the Up button
            ActionBar actionBar = getSupportActionBar();
            if (actionBar != null ) {
                actionBar.setDisplayHomeAsUpEnabled(true);
            }

        } else {
            startPlayback = false;
        }

        // create bundle for player activity fragment
        Bundle args = new Bundle();
        args.putParcelable(ARG_STATION, station);
        args.putInt(ARG_STATION_ID, stationID);
        args.putBoolean(ARG_PLAYBACK, startPlayback);

        PlayerActivityFragment playerActivityFragment = new PlayerActivityFragment();
        playerActivityFragment.setArguments(args);

        getFragmentManager().beginTransaction()
                .add(R.id.player_container, playerActivityFragment)
                .commit();

    }

}