I am developing my first application in phonegap (android).
Follow it this way and it should be working.
<!DOCTYPE html>
<html>
<head>
<title>Cordova Device Ready Example</title>
<script type="text/javascript" charset="utf-8" src="cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8">
// Call onDeviceReady when Cordova is loaded.
//
// At this point, the document has loaded but cordova-1.7.0.js has not.
// When Cordova is loaded and talking with the native device,
// it will call the event `deviceready`.
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// Cordova is loaded and it is now safe to make calls Cordova methods
//
function onDeviceReady() {
// Now safe to use the Cordova API
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>
Also check the Android example folder in the Cordova 1.7 download.
I got a solution for my one!! It's really simple problem on acquaintance.
We usually develop one cordova(phonegap) project, and then copy all related files (/www) to another one. but I realized Cordova file (cordova-2.2.0 now) is different between platforms.
Do not copy even cordova file. Use original example one on the platform.
not sure for every case. is this helpful? :)
For everyone who is still in trouble looking for solution - check the alternative .js files imported into your index.html, for example the index.js might have its own device ready call and function, therefore blocking your custom one.