包裹:无法编组值org.jivesoftware.smack.tcp.XMPPTCPConnection

时间:2016-02-17 08:23:08

标签: java android parcelable

我是Android和Parcelable界面的初学者。我只是想发送

private XMPPTCPConnection xmpptcpConnection;

这上面的XMPPTCPConnection对象从一个Activity到另一个Activity.But我错误收到错误:

java.lang.RuntimeException: Parcel: unable to marshal value org.jivesoftware.smack.tcp.XMPPTCPConnection@342f1d60
                                                                               at android.os.Parcel.writeValue(Parcel.java:1337)
                                                                               at com.example.rahul.samplesmack.Def.writeToParcel(Def.java:31)

以下是我的java代码:

public class Def implements Parcelable {

private XMPPTCPConnection xmpptcpConnection;

public void setXmpptcpConnection(XMPPTCPConnection xmpptcpConnection)
{
    this.xmpptcpConnection = xmpptcpConnection;
}
public XMPPTCPConnection getXmpptcpConnection()
{
    return xmpptcpConnection;
}

@Override
public int describeContents() {
    return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
    dest.writeValue(xmpptcpConnection); //I am getting Error here!!!!!
}

public Def(){}
protected Def(Parcel in) {
    xmpptcpConnection = (XMPPTCPConnection) in.readValue(XMPPTCPConnection.class.getClassLoader());
}

public static final Creator<Def> CREATOR = new Creator<Def>() {
    @Override
    public Def createFromParcel(Parcel in) {
        return new Def(in);
    }

    @Override
    public Def[] newArray(int size) {
        return new Def[size];
    }
};

}

0 个答案:

没有答案