Cordova相机PictureSourceType PHOTOLIBRARY v SAVEDPHOTOALBUM

时间:2013-10-02 18:45:26

标签: javascript android cordova

这些值都没有用于在Android的手机屏幕应用程序中启动照片库!!!

使用任何此值调用getPicture方法时,它不会拉出照片库。

我使用phonegap构建云服务构建应用程序

请帮忙,

示例代码 -

function getPhoto(source) {
  alert("getting photo");
  // Retrieve image file location from specified source
  navigator.camera.getPicture(onPhotoURISuccess, onFail, { destinationType: destinationType.FILE_URI, sourceType: source });
}

2 个答案:

答案 0 :(得分:8)

Camera.PictureSourceType.PHOTOLIBRARY == entire library

Camera.PictureSourceType.SAVEDPHOTOALBUM == camera photo album

如果您希望用户将手机上的任何图片上传到PHOTOLIBRARY。 或者,如果您希望用户仅上传手机摄像头拍摄的照片,请使用SAVEDPHOTOALBUM

答案 1 :(得分:0)

可能会低于代码行帮助你。

function getImage()
{
    // Retrieve image file location from specified source
    navigator.camera.getPicture(onCapturePhotoSuccess, onCapturePhotoError,{ quality: 80, 
        destinationType: navigator.camera.DestinationType.DATA_URL,
        sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
    });
}

function onCapturePhotoSuccess(imageURI) 
{   
    var smallImage = document.getElementById('id_for_setting_pic_somewhere_in_html');
        smallImage.src = "data:image/jpeg;base64," + imageURI;
}


function onCapturePhotoError(message) 
{
    console.log('Captured Failed because: ' + message); 
}