Passar objeto entre Activitys

Estou precisando enviar um objeto de uma activity para outra. Eu até consigo passar quando crio um novo objeto (Contact dataModel = new Contact():wink: mas quando ele está iniciado como segue abaixo não funciona. Estou quebrando bastante a cabeça com isso. Alguém pode me dar uma luz?

        Private contact dataMovel;

private void ShowRecords(){
    _name = name.getText().toString();

    final ArrayList<Contact> contacts = new ArrayList<>(db.getAllContacts(_name));
    data=new dataAdapter(this, contacts);

    lv.setAdapter(data);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            dataModel = contacts.get(position);
            Toast.makeText(getApplicationContext(),String.valueOf(dataModel.getID()), Toast.LENGTH_SHORT).show();

           Intent intent = new Intent(activity_busca.this, activity_atualizar.class);
            Contact contato = dataModel;

            Bundle bundle = new Bundle();
            bundle.putSerializable("contato", contato);
            
            intent.putExtras(bundle);

            startActivity(intent);
        
        }
    });


}

Seu objeto contato está seriavel?
Intent está mesmo conseguindo pega o contexto?
Qual o erro que ele devolve no log?

Olá amigo!

O objeto está Serializable.
Como vejo se o contexto está certo?
Estou carregando direto no android a aplicação.

Se não estiver, já aparece em tempo de compilação.
Preciso do log para saber realmente o que está acontecendo, talvez não tenha nada haver com a activity que você mandou, hehe.

Olá jonathan.sky, realmente o problema não estava na activity. Eu estou usando uma classe “Contact” e nela tenho uma imagem do tipo byte[], deixei essa imagem como transient e o objeto foi passado para outra activity. Agora preciso passar a imagem também. Tentei usando os métodos writeObject e readObject mas não deu certo ou implementei errado os métodos. Alguém sabe como resolver?

Segue a classe Contact:

public class Contact implements Serializable {

//private variables
int _id;
String _fname;
String _rg;
String _cpf;
String _pai;
String _mae;
transient byte[] _img;



// Empty constructor
public Contact(){

}
// constructor
public Contact(int id, String fname, String rg, String cpf, String pai, String mae, byte[] img){
    this._id = id;
    this._fname = fname;
    this._rg = rg;
    this._cpf = cpf;
    this._pai = pai;
    this._mae = mae;
    this._img = img;

}

// constructor
public Contact(String fname, String rg, String cpf, String pai, String mae, byte[] img){

    this._fname = fname;
    this._rg = rg;
    this._cpf = cpf;
    this._pai = pai;
    this._mae = mae;
    this._img = img;

}

// getting ID
public int getID(){
    return this._id;
}

// setting id
public void setID(int id){
    this._id = id;
}

// getting first name
public String getFName(){
    return this._fname;
}

// setting first name
public void setFName(String fname){
    this._fname = fname;
}

// getting rg
public String getRG(){ return this._rg; }

// setting rg
public void setRG(String rg){ this._rg = rg; }

// getting cpf
public String getCPF(){ return this._cpf; }

// setting cpf
public void setCPF(String cpf){ this._cpf = cpf; }

// getting pai
public String getPai() { return this._pai; }

// setting pai
public void setPai(String pai) { this._pai = pai; }

// getting mae
public String getMae() { return this._mae; }

// setting mae
public void setMae(String mae) { this._mae = mae; }

//getting profile pic
public byte[] getImage(){
    return this._img;
}

//setting profile pic
public void setImage(byte[] b){
    this._img=b;
}

private void writeObject(ObjectOutputStream out) throws IOException {
    out.defaultWriteObject();
    out.writeObject(this._img);
}

private void readObject(ObjectInputStream in)
        throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    
    this._img = (byte[]) in.readObject();
}

}