0

The below function was working properly in android 10 but after updating to android 11 it does not work in apache cordova-phonegap

function clickPhoto(source) {
    navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 20,destinationType: Camera.DestinationType.FILE_URI});
};
  • I have the exact same problem. On Samsung Galaxy XCover Pro worked fine on Android 10, after udpating to Andorid 11 it doesn't work anymore. When calling navigator.camera.getPicture a .jpg file is created but the file is empty (0 KB). – user2929078 Mar 30 '21 at 07:34

1 Answers1

-1

Please check this. Worked for me.

I resolved the issue by changing the source code in CameraLauncher.java file, the issue is that android 11 does not allow access to URIs created from URI.fromFile from one application to another. For example, in the performcrop method we are generating a croppedUri = Uri.fromFile(createCaptureFile(this.encodingType, System.currentTimeMillis() + ""));

and passing it to other activity therefore the receiving application will not have access to the croppedUri and throws an error like Access Denied or Editing is not allowed for this image.

So in order to resolve that we need to create a URI from FileProvider.getUriForFile().

I know it may sound silly. but replace with the following in performCrop method solved it for me.

croppedUri = picUri;

It worked for me on Android 10 and 11.

https://github.com/apache/cordova-plugin-camera/issues/718#issuecomment-864517005

Roman
  • 1
  • 1