CameraKit / camerakit-android

Library for Android Camera 1 and 2 APIs. Massively increase stability and reliability of photo and video capture on all Android devices.
https://camerakit.io
MIT License
5.35k stars 878 forks source link

image wont saved on memory or gallery after capture listener run. error say open failed: EACCES (Permission denied) #609

Open AsyrafChingo opened 4 years ago

AsyrafChingo commented 4 years ago

Is this a bug report?

(Yes)

Have you read the Contributing Guidelines?

(no)

Environment

(Please include the following information along with any other relevant environment details.)

CameraKit Version:

Android Device: Samsung Galaxy A70

Android Version: 10 (API29)

Steps to Reproduce

(Write your steps here:)

  1. capture listener run from a button
  2. no error, but no picture saved on memori or gallery. it say Exception 'open failed: EACCES (Permission denied)' on Android

Expected Behavior

(Write what you thought would happen.)

Actual Behavior

(Write what happened. Add screenshots!)

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

(Include your CameraKit setup and usage.)

alfonsotesone commented 4 years ago

Unfortunately I have also encountered the same problem, is there no way to solve it?

alfonsotesone commented 4 years ago

I managed to get around the problem. Essentially you need to use an AsyncTask to save the images. 😁

AshfaqueAhmed-HnH commented 4 years ago

You need to provide the read and write access permission

 private void requestWriteStorageRuntimePermission() {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this,
                    new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                    PERMISSIONS_REQUEST_STORAGE_CODE);
        } else {

        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        switch (requestCode) {
            case PERMISSIONS_REQUEST_STORAGE_CODE: {
                // If request is cancelled, the result arrays are empty.
                if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {

                } else {
                    // permission denied,
                    ActivityCompat.requestPermissions(this,
                            new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
                            PERMISSIONS_REQUEST_STORAGE_CODE);
                }
                return;
            }
        }
    }