2013-10-02 97 views
4

沒有這個值的工作來推出android的phonegap應用程序中的照片庫!科爾多瓦相機PictureSourceType PHOTOLIBRARY v SAVEDPHOTOALBUM

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 }); 
} 
+0

您可以控制日誌源和destinationType以查看調用getPhoto時的實際內容嗎?另外我假設onPhotoURISuccess和OnFail是在代碼中其他地方定義的函數,對嗎? –

+0

是onPhotoURISuccess和OnFail在代碼 –

+0

控制檯日誌源和目標類型中的其他位置定義在構建中?在Android手機? –

回答

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); 
} 
8

Camera.PictureSourceType.PHOTOLIBRARY == entire library

Camera.PictureSourceType.SAVEDPHOTOALBUM == camera photo album

如果希望用戶上傳他們的電話棍子任何圖像PHOTOLIBRARY。 或者,如果您希望用戶只上傳手機攝像頭拍攝的照片,請使用SAVEDPHOTOALBUM

+0

這是在哪裏記錄的?我正在使用SAVEDPHOTOALBUM,我可以上傳我的Nexus 6上的任何內容 – Mirko

+0

此鏈接https://github.com/apache/cordova-plugin-camera引用了這兩個選項,但沒有清楚地解釋用例。我在2014年使用過,圖書館可能已經改變了。 –

+0

我發現在Android上這兩個選項都是一樣的。 – Mirko