I have this situation: a Class A (that implements interface I), a Modal and a Class B (that implements interface I).
The Class A open the modal, and from the modal I go to class B. In class B I want to return to the Class A with the Modal updated (Not implemented yet).
I'm trying to pass an interface between the two activities but I recive this error (I already extends Serializable in Interface):
Caused by: java.io.NotSerializableException: com.google.android.material.textview.MaterialTextView
Class A
@Override
public void showList() {
Intent intent = new Intent(this, SelectMethod.class);
intent.putExtra("iHome", this);
startActivity(intent);
}
Modal
# Function when click button and go to the class B
btn_select_method.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iHome.showList();
}
});
Class B (SelectMethod)
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
intent.getSerializableExtra("iHome");
}
Interface
public interface Ihome extends Serializable {
void showList();
}
question from:
https://stackoverflow.com/questions/65601761/pass-an-interface-between-activities-in-intent 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…