Когда я запускаю код моего приложения через App PhoneGap, мое приложение работает.Но если код превращает его в apk и устанавливает его на моем телефоне с Android, кнопка запуска камеры и загрузки фотографии на сервер не работает.Я принес вам код:
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'" />
<title>My app</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Script -->
<script type="text/javascript" src="cordova.js" ></script>
<script type='text/javascript' src='jquery-3.0.0.js' ></script>
</head>
<body>
<div align="center" id="logo"><img src="img/logo.png" width="50%"></div>
<div style="margin:0 auto; width:30%!important;text-align: center;">
<img src="img/cam3.jpg" id='img' style="width: 100px; height: 100px;">
</div><br/>
<div style="width:100%; text-align:center; padding:10px;">
<div class="text-center mt-4">
<button id='but_take' type="button" class="btn btn-primary" >Cattura reperto</button>
</div>
<div style="margin-top: 30px; " class="text-center mt-4">
<a type="button" class="btn btn-info" href="#" onclick="window.open('https://myserverexample.com/img.php', '_system');">Guarda reperti</a>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script type='text/javascript'>
$(document).ready(function(){
// take picture from camera
$('#but_take').click(function(){
navigator.camera.getPicture(onSuccess, onFail, { quality: 20,
destinationType: Camera.DestinationType.FILE_URL
});
});
// Change image source and upload photo to server
function onSuccess(imageURI) {
// Set image source
var image = document.getElementById('img');
image.src = imageURI + '?' + Math.random();
var options = new FileUploadOptions();
options.fileKey = "file";
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
options.mimeType = "image/jpeg";
var params = {};
params.value1 = "test";
params.value2 = "param";
options.params = params;
options.chunkedMode = false;
// load image to server
var ft = new FileTransfer();
ft.upload(imageURI, "http://myserverexample.com/load-image.php", function(result){
alert('image load ' );
}, function(error){
alert('error : ' + JSON.stringify(error));
}, options);
}
function onFail(message) {
alert('No Image: ' + message);
}
});
</script>
</body>
</html>
Что мне нужно сделать, чтобы мой код работал на Android?есть ли способ увидеть ошибки разрыва телефона apk на Android?спасибо