我正在使用HTML5,CSS3,Javascript,Phonegap构建Andriod移动应用
我无法在Android设备上打开相册或图书馆。我得到错误说无法读取属性PictureSourceType | PHOTOLIBRARY | eclipse logcat中的SAVEDPHOTOALBUM?请帮帮忙?
logcat的
06-30 01:02:37.268: D/CordovaLog(1156): file:///android_asset/www/profile_uploadonly.html: Line 24 : Uncaught TypeError: Cannot read property 'PictureSourceType' of undefined
06-30 01:02:37.268: E/Web Console(1156): Uncaught TypeError: Cannot read property 'PictureSourceType' of undefined at file:///android_asset/www/profile_uploadonly.html:24
06-30 01:02:56.618: D/CordovaLog(1156): file:///android_asset/www/profile_uploadonly.html: Line 90 : Uncaught TypeError: Cannot read property 'PHOTOLIBRARY' of undefined
06-30 01:02:56.618: E/Web Console(1156): Uncaught TypeError: Cannot read property 'PHOTOLIBRARY' of undefined at file:///android_asset/www/profile_uploadonly.html:90
06-30 01:03:02.719: D/CordovaLog(1156): file:///android_asset/www/profile_uploadonly.html: Line 91 : Uncaught TypeError: Cannot read property 'SAVEDPHOTOALBUM' of undefined
06-30 01:03:02.719: E/Web Console(1156): Uncaught TypeError: Cannot read property 'SAVEDPHOTOALBUM' of undefined at file:///android_asset/www/profile_uploadonly.html:91
。 profile_uploadonly.html
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova_plugins.js"></script>
<script type="text/javascript" charset="utf-8" src="File.js"></script>
<script type="text/javascript" charset="utf-8" src="FileTransfer.js"></script>
<script type="text/javascript" charset="utf-8" src="FileTransferError.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
var pictureSource; // picture source
var destinationType; // sets the format of returned value
document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
function onPhotoDataSuccess(imageData) {
var smallImage = document.getElementById('smallImage');
smallImage.style.display = 'block';
smallImage.src = "data:image/jpeg;base64," + imageData;
}
function onPhotoURISuccess(imageURI) {
alert("inside large image")
var largeImage = document.getElementById('largeImage');
largeImage.style.display = 'block';
largeImage.src = imageURI;
}
function getPhoto(source) {
navigator.camera.getPicture(onPhotoURISuccess, onFail, { quality: 50,
destinationType: destinationType.FILE_URI,
sourceType: source });
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
</head>
<body>
<button onclick="getPhoto(pictureSource.PHOTOLIBRARY);">From Photo Library</button><br>
<button onclick="getPhoto(pictureSource.SAVEDPHOTOALBUM);">From Photo Album</button><br>
<img style="display:none;width:60px;height:60px;" id="smallImage" src="" />
<img style="display:none;" id="largeImage" src="" />
</body>
</html>