1

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.

Sean
  • 2,967
  • 2
  • 29
  • 39
  • I hope you already handled both `Camera` & `Storage` permission. Also, please take a look on [this solution](https://stackoverflow.com/a/11470571/3682565) or [this one](https://stackoverflow.com/a/13185464/3682565). – NamNH Apr 22 '19 at 02:13
  • Check [this](https://stackoverflow.com/questions/24730581/android-how-to-use-granturipermission-to-be-able-to-create-and-send-an-email-wi/44820161) – Soham Apr 22 '19 at 04:08

0 Answers0