Iām building my first Cordova 4.0 application and I really need help, as I will show a demo version of this tmrw application ...
When I try to access the network and camera APIs ( navigator.connection and navigator.camera respectively), they always return undefined.
I have this right in my Android manifest:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
And here are the installed plugins:
org.apache.cordova.camera 0.3.3 "Camera" org.apache.cordova.console 0.2.11 "Console" org.apache.cordova.device 0.2.12 "Device" org.apache.cordova.network-information 0.2.13 "Network Information"
I also copied the cordova.js file from the platform folder and added the <SCRIPT TYPE="text/javascript" src="js/cordova.js"></SCRIPT> to my index.html. Also here is an example of my code where I am trying to access the camera API:
document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { $(document).on('click', '.camera', function(){ if (!navigator.camera) { alert("Camera API not supported", "Error"); return; } var options = { quality: 50, destinationType: Camera.DestinationType.DATA_URL, sourceType: 1,
When I run this, I always get the warning "Camera API not supported", which means undefined.
What am I missing?
source share