Android中Intent传递对象的有两种方法:
1.Bundle.putSerializable(Key,Object);
2.Bundle.putParcelable(Key, Object);

public class xx implements Serializable {

}

public class Book implements Parcelable {
private String bookName;
private String author;
private int publishTime;

public static final Parcelable.Creator<Book> CREATOR = new Creator<Book>() {
public Book createFromParcel(Parcel source) {
Book mBook = new Book();
mBook.bookName = source.readString();
mBook.author = source.readString();
mBook.publishTime = source.readInt();
return mBook;
}
public Book[] newArray(int size) {
return new Book[size];
}
};

public int describeContents() {
return 0;
}

public void writeToParcel(Parcel parcel, int flags) {
parcel.writeString(bookName);
parcel.writeString(author);
parcel.writeInt(publishTime);
}
}

// Bundle.putSerializable(Key,Object);
Person mPerson = new Person();
mPerson.setName("xxx");
Intent mIntent = new Intent(this, Obj.class);
Bundle mBundle = new Bundle();
mBundle.putSerializable(Key, mPerson);
mIntent.putExtras(mBoundle);

// Bundle.putParcelable(Key, Object);
Book mBook = new Book();
mBook.setBookName("Awefw");
mBook.setAuthor("xx");
mBook.setPublishTime("235");
Intent mIntent = new Intent(this, xx.class);
Bundle mBundle = new Bundle();
mBundle.putParcelable(key, mBook);
mIntent.putExtras(mBundle);
startActivity(mIntent);

更多相关文章

  1. android pull解析xml最简单的方法
  2. Android PopupWindow 的方法 & 弹出窗口方法
  3. Android 获取默认输入法,以及获取输入法的列表的方法
  4. Android 开发图片压缩/缩略图的方法
  5. android回到桌面的方法
  6. Android创建ListView使用两种适配器的简单方法
  7. 【Android】图像中Drawable向Bitmap的两种转换方法
  8. android获取sd卡路径方法

随机推荐

  1. android sdk 各个版本的区别
  2. Android中使用Serializable和Parcelable
  3. 旋转中 android 的视图按钮
  4. (超详细)android中SqLite数据库的使用(一文
  5. Android 系统的架构
  6. AlertDialog实现普通对话框和登录对话框
  7. Android(安卓)VideoView如何播放RTSP的流
  8. Android开发(二十七)——android:layout_we
  9. Android EventBus框架入门
  10. android 自学日记(三) ---Intent