PhoneGap call getPicture () is not saved in Gallery on Android phone

I am trying to use the PhoneGap function to take a picture from my Android phone and save it in the phone gallery. I had no problems running and running their full example, but the code never saves the image. We tested on the Iphone and did not experience any problems, so I wonder if I am not doing something wrong or is this another issue with Android.

Telephone conversation example

Listed below are the steps I took based on what I saw on the Internet.

Add to app / res / xml / config.xml
<plugin name="Camera" value="org.apache.cordova.CameraLauncher" /> 
Add to manifest file
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
Change the parameters in getPicture () to enable the saveToPhotoAlbum option
 navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: destinationType.DATA_URL, saveToPhotoAlbum: true }); 

I also tried changing the destination type to FILE_URI , but still no luck. The application can still display the captured image, so I know that it is so far, I just do not know why it does not save in the gallery.

+4
source share
1 answer

I stayed stuck for the same issue, but using jQuery mobile. I also copied a working example of the apache cordova plug-in camera. I just simply commented out all the code in the provided .js file and pasted the following code copied from. It worked fine, but with one problem, this image will be saved below with the date of 1970, but it will be saved. The code is below.

 $('#capturePhotoButton').on('click', function () { alert('capturePhotoButton click() called'); cameraGetPicture(); }); function cameraGetPicture() { navigator.camera.getPicture(imageReceived, cameraFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI, allowEdit: false, saveToPhotoAlbum: true, correctOrientation: true }); } function imageReceived(imageURI) { var image = document.querySelector('img#smallImage'); image.src = imageURI; imageURI = new steroids.File({ path: "image.png", relativeTo: steroids.app.userFilesPath }); } function cameraFail(message) { alert("Camera error: " + message); } 
+1
source

Source: https://habr.com/ru/post/1487950/


All Articles