My problem is want to send interface instance to camera activity so that in onActivityResult
I can call method of that interface implementation. I tried following logic that make custom interface made serializable
but got error.
I just want to know proper way to make custom interface serializable, I used below code
public interface ImageListener extends Serializable{
public void onImageCaptureResult(int requestCode, int resultCode, Intent data);
}
Implementation is in my fragment
ImageListener imageListener = new ImageListener() {
@Override
public void onImageCaptureResult(int requestCode, int resultCode, Intent data) {
displayToast("image got in fragment ");
}
};
but when I put instance of interface in intent.putExtra
like this
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("il",imageListener); // ERROR AT THIS LINE
getActivity().startActivityForResult(intent, ConstantsTags.REQUEST_CAMERA);
I got Exception java.io.NotSerializableException
.
Please guide me how can I achieve this.