Check that fragment is added to activity to prevent crash

This commit is contained in:
misaochan 2018-01-25 03:35:12 +10:00
parent 05044d4b9a
commit dc06fe789f

View file

@ -70,6 +70,9 @@ public class ContributionController {
requestWritePermission(fragment.getContext(), takePictureIntent, lastGeneratedCaptureUri);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, lastGeneratedCaptureUri);
if (!fragment.isAdded()) {
return;
}
fragment.startActivityForResult(takePictureIntent, SELECT_FROM_CAMERA);
}
@ -79,6 +82,9 @@ public class ContributionController {
pickImageIntent.setType("image/*");
Timber.d("startGalleryPick() called with pickImageIntent");
//TODO Add fix for IllegalStateException here
if (!fragment.isAdded()) {
return;
}
fragment.startActivityForResult(pickImageIntent, SELECT_FROM_GALLERY);
}