Search code examples
androidcordovaandroid-gallery

Phonegap 2.0 saveToPhotoAlbum:false not working properly on certain Android devices


A phonegap application we have implemented makes use of the Camera for capturing images. Once the image is captured its displayed temporarily in the application using an img tag and is uploaded to a server as a base64 encoded string.

Our requirement is to prevent any form of the image saving on the gallery of the mobile.

Intending to solve this we have used the SaveToPhotoAlbum : false option provided in the phonegap 2.0 framework

An extract of the code is displayed below

        navigator.camera.getPicture(captureSurfaceSuccess(surface), captureSurfaceFail, {
        destinationType: Camera.DestinationType.DATA_URL,
        sourceType: Camera.PictureSourceType.CAMERA,
        quality: 30,
        targetWidth: 1600,
        targetHeight: 1200,
        saveToPhotoAlbum: false
    });

We have tried DATA_URL and FILE_URI but have notice the following behavior in different mobiles.

  1. Some devices do not save to the gallery - the requirement
  2. Some devices save to the Gallery and to the temporary location. (FILE_URI)
  3. Some devices save only to the Gallery.

Post here: Deleting a gallery image after camera intent photo taken explains that this is a native android issue, but the solution suggested to delete the last file is not applicable since saving at the gallery should be prohibited by all means.

We want to know any alternatives which solves this issue, or availability of a custom camera plugin for phonegap that prevent this issue and sends us the raw data.

Also Note: Currently Android is the only targeted mobile platform


Solution

  • We managed to solve this issue by using our own SurfaceView Camera plugin which would capture the image and compress it and pass as a base64 string to the Cordova WebView. This allowed us to manage the image in memory without Cordovas implicit saving to the gallery.