0
I’m trying to make a "Hello World" in Ordova, it’s a screen with a button that triggers the camera, it’s not necessary to do anything else, just trigger the camera. the steps I took.
- Cordova create hello com.bruno.hello hello
- hello cd
- Cordova plataforms add android
- Cordova build
- npm install Cordova-plugin-camera
- I edited the index.html as shown in the section below
<script type="text/javascript">
function teste(){
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});
}
function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
</script>
<button onclick="teste(); ">TESTAR</button>
- Cordova run android
The emulator is pressed with the button, but when I press, nothing happens
I tried to follow the example of the link https://cordova.apache.org/docs/en/1.6.1/cordova/camera/camera.getPicture.html
unsuccessful
I’m using Windows 10 64bits
A question, have you ever tried to run on a real device? I had problems with Cordova running on the SDK virtual machine. Plug the device, enable USB debugging and have the drivers installed, then run Cordova run android
– Renan Cavalieri
@Renancavalieri tried yes, but with the phonegap Veloper, I do not know if it is the same thing, but ran the app with the same problem
– Bruno Gomes
In this case then it remains to be seen if you have put permissions for your application, check these files and see if they have the following lines https://cordova.apache.org/docs/en/2.5.0/cordova/camera/camera.html
– Renan Cavalieri
@Renancavalieri this is on Androidmanifest????
– Bruno Gomes
Yes, although this documentation is outdated, the paths are the same, at least they were until version 4.0 which was the one I used.
– Renan Cavalieri
@Renancavalieri only has uses-permission android:name="android.permission.CAMERA", how do I include this line there? which tag I use?
– Bruno Gomes
Let’s go continue this discussion in chat.
– Bruno Gomes
an important detail, you may be using different version documentation to which you are installed, make sure of it. The most recent can be accessed at : https://cordova.apache.org/docs/en/latest/cordova/plugins/pluginapis.html
– Vinicius Dutra