From my Activity, which extends SherlockFragmentActivity (from the excellent ActionBarSherlock library), I make a simple request to get an image from the camera:
public void getPhoto() {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// .....
}
When executed, onActivityResult() is called with a resultCode of zero (and a matching requestCode) when the camera app opens (before taking a picture). If I then take a picture and accept it, onActivityResult() is not called.
I'm aware there's a similar bug in Fragment in the Support Library, but I'm seeing this issue in Fragment and Activity.
I've checked and I'm calling the right startActivityForResult() (i.e. on Fragment or Activity), and I've stepped through the code everywhere I can think to. I'm starting to wonder whether the Support Library bug that means onActivityResult isn't called in Fragment also affects Activity when using ActionBarSherlock, but I can't believe ABS breaks onActivityResult().
What have I missed?
The Activity was specified as singleInstance in the manifest. I now know that this is incompatible with startActivityForResult() and when the Activity was changed to singleTop, it all works as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With