I have a fragment, where I have a button to choose an image from a gallery. The gallery is open successfully, but when I choose the image, I do not get the result from activity. So I consider to use a callback (interface). However, I do know how.
Could you suggest me something please?
interface
public interface CallbackListener {
void onPhotoTake(String url);
}
in fragment click
@OnClick(R.id.addPhoto) void photo() {
if (isStoragePermissionGranted()) {
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
context.startActivityForResult(i, RESULT_LOAD_IMAGE);
}
}
activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
- here I would like to send result back to fragment using interface