I have some code using MediaStore.ACTION_IMAGE_CAPTURE intent to capture thumbnails. It has been working until recently :-(
The following is my code:
protected void takePicture() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
if (intent.resolveActivity(getMainActivity().getPackageManager()) != null) {
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
} else {
Log.e(tag, ">>No Activity available to handle camera photo");
}
}
// ...
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == Activity.RESULT_OK) {
enableUserInteraction(false);
Bitmap bmp = (Bitmap) data.getExtras().get("data");
}
} else {
// user canceled
}
}
(permission stuffs omitted)
my code pretty much copied from the following android link https://developer.android.com/training/camera/photobasics
In my newer device running Android 9, the activity resultCode is always canceled, while same app/code still working on older Android version.
Any advice, fixes, or workaround are highly appreciated.