Android Can';t发送了一个带有intent-Serializable类的类-

Android Can';t发送了一个带有intent-Serializable类的类-,android,android-intent,serializable,Android,Android Intent,Serializable,我尝试使用putExtra方法(字符串名称,可序列化对象) 将类调用添加到意图 电话号码: package com.example.model; import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import android.location.Address; import android.os.Parcel; import android.os.Parcelable; publi

我尝试使用putExtra方法(字符串名称,可序列化对象) 将类调用添加到意图

电话号码:

package com.example.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;

import android.location.Address;
import android.os.Parcel;
import android.os.Parcelable;

public class Call implements Serializable
{



    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    /**
     * 
     */
    //private static final long serialVersionUID = 1L;
    static int idCount=1;
    int id;
    String name;
    Address address;
    CallStatus status;
    ArrayList<SparePart> spareParts;
    String caller;
    Date callDate;
    Technician technician;
    ArrayList<String> toDoList;
    public Call()
    {

    }
    public Call(CallStatus status, ArrayList<SparePart> spareParts,
            String caller, Date callDate, Technician technician,Address address)
    {
        id=idCount;
        idCount++;
        this.address=address;
        this.status = status;
        this.spareParts = spareParts;
        this.caller = caller;
        this.callDate = callDate;
        this.technician = technician;
    }

    /**
     * @return the id
     */
    public int getId()
    {
        return id;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        return "Order [id=" + id + ", status=" + status + ", spareParts="
                + spareParts + ", caller=" + caller + ", callDate=" + callDate
                + ", technician=" + technician + "]";
    }
    /**
     * @param id the id to set
     */
    public void setId(int id)
    {
        this.id = id;
    }
    /**
     * @return the status
     */
    public CallStatus getStatus()
    {
        return status;
    }
    /**
     * @param status the status to set
     */
    public void setStatus(CallStatus status)
    {
        this.status = status;
    }
    /**
     * @return the spareParts
     */
    public ArrayList<SparePart> getSpareParts()
    {
        return spareParts;
    }
    /**
     * @param spareParts the spareParts to set
     */
    public void setSpareParts(ArrayList<SparePart> spareParts)
    {
        this.spareParts = spareParts;
    }
    /**
     * @return the caller
     */
    public String getCaller()
    {
        return caller;
    }
    /**
     * @param caller the caller to set
     */
    public void setCaller(String caller)
    {
        this.caller = caller;
    }
    /**
     * @return the callDate
     */
    public Date getCallDate()
    {
        return callDate;
    }
    /**
     * @param callDate the callDate to set
     */
    public void setCallDate(Date callDate)
    {
        this.callDate = callDate;
    }
    /**
     * @return the technicianId
     */
    public Technician getTechnicianId()
    {
        return technician;
    }
    /**
     * @param technicianId the technicianId to set
     */
    public void setTechnicianId(Technician technician)
    {
        this.technician = technician;
    }
    /**
     * @return the name
     */
    public String getName()
    {
        return name;
    }
    /**
     * @param name the name to set
     */
    public void setName(String name)
    {
        this.name = name;
    }
    /**
     * @return the address
     */
    public Address getAddress()
    {
        return address;
    }
    /**
     * @param address the address to set
     */
    public void setAddress(Address address)
    {
        this.address = address;
    }
    /**
     * @return the technician
     */
    public Technician getTechnician()
    {
        return technician;
    }
    /**
     * @param technician the technician to set
     */
    public void setTechnician(Technician technician)
    {
        this.technician = technician;
    }
    /**
     * @return the toDoList
     */
    public ArrayList<String> getToDoList()
    {
        return toDoList;
    }
    /**
     * @param toDoList the toDoList to set
     */
    public void setToDoList(ArrayList<String> toDoList)
    {
        this.toDoList = toDoList;
    }

}
技师代码:

package com.example.model;

import java.io.Serializable;
import java.util.ArrayList;

import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Phone;
public class Technician implements Serializable
{
    /**
     * 
     */
    private static final long serialVersionUID = 3L;
    static int idCount=1;
    int id;
    String name;
    String userName;
    String password;
    ArrayList<Call> orders;
    TechnicianRank rank;
    String securityQuestion;
    String securityAnswer;
    Phone phone;
    Email email;
    /**
     * @return the id
     */
    public int getId()
    {
        return id;
    }
    /**
     * @param id the id to set
     */
    public void setId(int id)
    {
        this.id = id;
    }
    /**
     * @return the userName
     */
    public String getUserName()
    {
        return userName;
    }
    /**
     * @param userName the userName to set
     */
    public void setUserName(String userName)
    {
        this.userName = userName;
    }
    /**
     * @return the password
     */
    public String getPassword()
    {
        return password;
    }
    /**
     * @param password the password to set
     */
    public void setPassword(String password)
    {
        this.password = password;
    }
    /**
     * @return the orders
     */
    public ArrayList<Call> getOrders()
    {
        return orders;
    }
    /**
     * @param orders the orders to set
     */
    public void setOrders(ArrayList<Call> orders)
    {
        this.orders = orders;
    }
    /**
     * @return the rank
     */
    public TechnicianRank getRank()
    {
        return rank;
    }
    /**
     * @param rank the rank to set
     */
    public void setRank(TechnicianRank rank)
    {
        this.rank = rank;
    }
    /**
     * @return the securityQuestion
     */
    public String getSecurityQuestion()
    {
        return securityQuestion;
    }
    /**
     * @param securityQuestion the securityQuestion to set
     */
    public void setSecurityQuestion(String securityQuestion)
    {
        this.securityQuestion = securityQuestion;
    }
    /**
     * @return the securityAnswer
     */
    public String getSecurityAnswer()
    {
        return securityAnswer;
    }
    /**
     * @param securityAnswer the securityAnswer to set
     */
    public void setSecurityAnswer(String securityAnswer)
    {
        this.securityAnswer = securityAnswer;
    }
    /**
     * @return the phone
     */
    public Phone getPhone()
    {
        return phone;
    }
    /**
     * @param phone the phone to set
     */
    public void setPhone(Phone phone)
    {
        this.phone = phone;
    }
    /**
     * @return the email
     */
    public Email getEmail()
    {
        return email;
    }
    /**
     * @param email the email to set
     */
    public void setEmail(Email email)
    {
        this.email = email;
    }
    /**
     * @return the name
     */
    public String getName()
    {
        return name;
    }
    /**
     * @param name the name to set
     */
    public void setName(String name)
    {
        this.name = name;
    }
}
呼吁意图:

Intent intent2 = new Intent(


ShowOrders.this, SpareParts.class);


intent2.putExtra("Call",myList.get(position));

startActivity(intent2);
当myList包含许多调用指令时

我没有运气就试图寻找答案。
有人能帮我吗?

我也发现这个方法有一些问题。 因此,您可以将您的信息放入
捆绑包中
试试这个。 Api是可序列化的对象

private void testBundle() {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    intent.setClass(this, FeedActivity.class);//this - Current Activity
    bundle.putSerializable("API", api);
    intent.putExtras(bundle);
    startActivity(intent);
}
要从bundle获取信息,请使用下一个代码

api = (Api) this.getIntent().getExtras().getSerializable("API");

您得到的错误是什么?请只发布你的课程的相关代码。我们不希望看到成千行的接受者和接受者。什么不起作用?
SpareParts.onCreate()的代码在哪里?
private void testBundle() {
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    intent.setClass(this, FeedActivity.class);//this - Current Activity
    bundle.putSerializable("API", api);
    intent.putExtras(bundle);
    startActivity(intent);
}
api = (Api) this.getIntent().getExtras().getSerializable("API");