本文整理汇总了Java中android.os.Bundle.putParcelable方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.putParcelable方法的具体用法?Java Bundle.putParcelable怎么用?Java Bundle.putParcelable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Bundle
的用法示例。
在下文中一共展示了Bundle.putParcelable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例2: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
}
示例3: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
}
示例4: writeToParcel
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例5: startServiceWithPlaylist
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
示例6: createDocument
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
示例7: playFromUri
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
示例8: getViewAt
import android.os.Bundle; //导入方法依赖的package包/类
@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;
}
示例9: saveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
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);
}
示例10: createChooser
import android.os.Bundle; //导入方法依赖的package包/类
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");
}
示例11: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@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);
}
示例12: onSaveInstanceState
import android.os.Bundle; //导入方法依赖的package包/类
@Override protected Parcelable onSaveInstanceState() {
super.onSaveInstanceState();
Bundle bundle = new Bundle();
bundle.putParcelable("superState", super.onSaveInstanceState());
bundle.putString("editText_title",mEditText.getText().toString());
return bundle;
}
示例13: newInstance
import android.os.Bundle; //导入方法依赖的package包/类
public static MediaGridFragment newInstance(Configuration configuration) {
MediaGridFragment fragment = new MediaGridFragment();
Bundle bundle = new Bundle();
bundle.putParcelable(EXTRA_CONFIGURATION, configuration);
fragment.setArguments(bundle);
return fragment;
}
示例14: buildArgsForEdit
import android.os.Bundle; //导入方法依赖的package包/类
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;
}
示例15: addAccount
import android.os.Bundle; //导入方法依赖的package包/类
@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;
}