В файле config.xml я добавил
<plugin name="cordova-plugin-camera" />
<plugin name="cordova-plugin-media-capture"/>
В файле index.html
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
...
<button onclick="capturePhoto();">Capture Photo</button>
Тогдав теге Javascript
<script>
var pictureSource; // picture source
var destinationType; // sets the format of returned value
// Wait for device API libraries to load
document.addEventListener("deviceready",onDeviceReady,false);
// device APIs are available
function onDeviceReady() {
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
}
// Called when a photo is successfully retrieved
function onPhotoDataSuccess(imageData) {
// Uncomment to view the base64-encoded image data
alert(imageData);
// Get image handle
var smallImage = document.getElementById('smallImage');
// Unhide image elements
smallImage.style.display = 'block';
// Show the captured photo
// The inline CSS rules are used to resize the image
smallImage.src = "data:image/jpeg;base64," + imageData;
}
function capturePhoto() {
alert("I am here");
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
При нажатии кнопки я получаю предупреждение «Я здесь», что означает, что кнопка html вызывает функцию capturePhoto ().И я не получаю никаких сообщений об ошибках!
Но камера не открывается!
Я использую онлайн https://build.phonegap.com/, чтобы получить apk
Я застрял на этом некоторое время .. любой совет, пожалуйста?