前些日子项目紧,一直没时间整理自个的东西,现在终于可以分享一些东西了
intent.bundle传递数据给目标activity的实例:
比如购物车用户输入的某些数据要传递下个切换页面-确认下单的activity,
Intent intent = new Intent(this, PayConfirmActivity.class); Bundle bundle = new Bundle(); bundle.putSerializable("payConfirmBean", payConfrimBan); intent.putExtra("payBundle", bundle); intent.putExtra("toId","gwc"); startActivity(intent); finish(); 注意:payConfrimBan 必须要序列化,我这里是让payConfrimBan implement serializable然后目标activity create方法中的代码Intent intent = getIntent(); mPayBundle = intent.getBundleExtra("payBundle"); if (mPayBundle != null) { mPayConfirmBean = (PayConfrimBan) mPayBundle.getSerializable("payConfirmBean"); }这样就在目标activity得到了购物车中的data;