apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
960 stars 1.52k forks source link

Its working but in Imagepicker not #876

Open durgavishwakarma opened 4 months ago

durgavishwakarma commented 4 months ago
          After investigating, the error comes from this method on CameraLauncher.java file : 
    public void onRequestPermissionResult(int requestCode, String[] permissions,
                                          int[] grantResults) {
        for (int r : grantResults) {
            System.out.println("PHOTO DEBUG - " + r);
         /*   if (r == PackageManager.PERMISSION_DENIED) {
                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
                System.out.println("PHOTO DEBUG - " + r);
                return;
            }
*/

        }
        switch (requestCode) {
            case TAKE_PIC_SEC:
                takePicture(this.destType, this.encodingType);
                break;
            case SAVE_TO_ALBUM_SEC:
                this.getImage(this.srcType, this.destType);
                break;
        }
    }

If I comment this section about comparing value of r and PackageManager.PERMISSION_DENIED value, camera and gallery work good. It means we are always getting -1 value even if we allow permissions. I'm not Android Expert but i try to get explanations, how to fix this permission section

Originally posted by @Houdhey in https://github.com/apache/cordova-plugin-camera/issues/797#issuecomment-1196472206

durgavishwakarma commented 4 months ago
          After investigating, the error comes from this method on CameraLauncher.java file : 
    public void onRequestPermissionResult(int requestCode, String[] permissions,
                                          int[] grantResults) {
        for (int r : grantResults) {
            System.out.println("PHOTO DEBUG - " + r);
         /*   if (r == PackageManager.PERMISSION_DENIED) {
                this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR));
                System.out.println("PHOTO DEBUG - " + r);
                return;
            }
*/

        }
        switch (requestCode) {
            case TAKE_PIC_SEC:
                takePicture(this.destType, this.encodingType);
                break;
            case SAVE_TO_ALBUM_SEC:
                this.getImage(this.srcType, this.destType);
                break;
        }
    }

If I comment this section about comparing value of r and PackageManager.PERMISSION_DENIED value, camera and gallery work good. It means we are always getting -1 value even if we allow permissions. I'm not Android Expert but i try to get explanations, how to fix this permission section

Originally posted by @Houdhey in #797 (comment)

its working for camera what next for image picker