2 andriod132 andriod132 于 2016.02.21 15:55 提问

intent传对象给broadcastreceiver,结果为空

![![图片说明](http://img.ask.csdn.net/upload/201602/21/1456041187_562685.png)图片说明图片说明

public class Student implements Parcelable {

    String name;
      int age;
      public static final Parcelable.Creator<Student> CREATOR=new Creator<Student>() {

        @Override
        public Student[] newArray(int size) {
            // TODO Auto-generated method stub
            return new Student[size];
        }

        @Override
        public Student createFromParcel(Parcel source) {
            // TODO Auto-generated method stub
            return new Student(source.readString(),source.readInt());
        }
    };
      Student(String name,int age){
          this.name=name;
          this.age=age;
      }
     public String getName(){
        return name;
      }
     public int getAge(){
            return age;
          }
    @Override
    public int describeContents() {
        // TODO Auto-generated method stub

        return 0;
    }
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        // TODO Auto-generated method stub
        dest.writeString(name);
        dest.writeInt(age);

    }
  }

1个回答

andriod132
andriod132   2016.02.21 15:57

图片说明

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!