I am using using cordova plugins for Camera & ImagePicker.
cordova-plugin-camera
cordova-plugin-image-picker
They are both working fine, however in order to get the Camera to work, I first need to give the phone permission to allow my app to access media, which is as expected.
Allow <appname> to access photos, media, and files on your device?
DENY ALLOW
When I access the ImagePicker, it fails, if I have not first allowed my app access to the media by first accessing the Camera. The ImagePicker does not prompt the user to allow access to media, it just fails.
Does anyone know how I can get the ImagePicker to prompt the user to allow access to media?
Could you provide some more information? What platform does this happen on? iOS or Android? Also, what version of the plugin,platform are you testing against?
Hmm, you might need to install the diagnostic plugin or the compat plugin.
The compat plugin is much simpler (just install and you’re done) and handles the permissions between older android and android 6x, which has a much different permissions API.
// Assume thisActivity is the current activity
int permissionCheck = ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.WRITE_CALENDAR);
Do you know in Ironic 2 how I would importContextCompatcordova-plugin-compat?
I ran in to the exact same issue with the camera and gallery access on Android 6.0.1 device.
THE FIX DONT : Do not request access for the CAMERA, it leads in to the issue of permission DENIED_ALWAYS (look in to Cordova Diagnostic Plugin Pull 33 for more details). I did try setting the below in the AndroidManifest.xml, but nothing seems to work for CAMERA.
I recently had a similar issue with image-crop plugin for ionic v1. In my own case, after I compiled my app and installed the apk on an android phone running on version 6.0.1. The application closes abruptly whenever I tried to select images from the phone’s gallery for cropping. Though it didn’t exhibit the behavior when I was testing on the ionic view app and in the avd emulator I had setup in android studio.
Anyway to cut the story short I came across a post which suggested I add this two tags to the android manifest file, which solved the problem in my own case:
None of the solutions work for me. I’m using ionic 3 with the latest Cordova and few different plugins that are accessing camera: barcode, camera, and gallery plugin. Barcode and gallery are working fine. They prompt properly for the permissions and accessing fine.
Camera throws error 20. I tested on a couple different Android phones( one had 6 and one had 8) and the behavior was the same.
I tried also using the diagnostic plugin mentioned above and ask for external storage authorization. I’m getting success back.
Any ideas?
cmd: Command failed with exit code 1 Error output:
D:\images\platforms\android\app\src\main\java\com\synconset\ImageFetcher.java:293: error: Entry is not public in LinkedHashMap; cannot be accessed from outside package
protected boolean removeEldestEntry(LinkedHashMap.Entry<Integer, Bitmap> eldest) ^
Note: D:\images\platforms\android\app\src\main\java\com\synconset\MultiImageChooserActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: D:\images\platforms\android\app\src\main\java\com\synconset\MultiImageChooserActivity.java uses unchecked or unsafe operations.