I have a fragment where I have a button for selecting an image from the gallery. The gallery is opened successfully, but when I select an image, I do not get the result from the activity. Therefore, I consider using a callback (interface). However, I know how.
Can you advise me something?
interface
public interface CallbackListener {
void onPhotoTake(String url);
}
in click fragment
@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 the result back to the fragment using the interface
source
share