Reputation: 321
My application works fine in emulator, but when I put it on my Android device (Samsung Galaxy Spica) I get error: The page at file:// says: gap:["Device","getDeviceInfo","Device0",true]
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Title</title>
<meta charset="utf-8">
<script type="text/javascript" src="javascript/phonegap.js"></script>
<script type="text/javascript">
alert("test1");
</script>
<link rel="stylesheet" href="css/style.css" />
</head>
<body onload="deviceReady()">
<script type="text/javascript">
alert("test2");
function deviceReady() {
alert("Ready");
}
</script>
</body>
</html>
I get all alerts. I found out that document.addEventListener("deviceready", onDeviceReady, false);
is not working on android device.
And there is another problem. When I click 'ok' or 'cancel' on The page at file://...
error, application closes in 5 seconds. What seems to be the problem?
*I use Dreamweaver CS5.5 to build application. Maybe there is a problem.. * and it's phonegap 1.0.0
DEBUG:
D/PhoneGapLog( 8235): file:///android_asset/www/javascript/phonegap.js: Line 624 : Error: SyntaxError: Parse error
I/Web Console( 8235): Error: SyntaxError: Parse error at file:///android_asset/www/javascript/phonegap.js:624
---- This is when app closes ----
I/WindowManager( 2163): WIN DEATH: Window{461efdd8 com.app.mobile/com.app.mobile.DefaultActivity paused=false}
I/ActivityManager( 2163): Process com.app.mobile (pid 8235) has died.
Upvotes: 0
Views: 1593
Reputation: 1383
You can use cordova-2.0.0.js this javascript lib for your code
and add below code in your js
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("Working properly");
}
Upvotes: 1
Reputation: 1556
use latest phonegap version 1.9.0 OR 2.1.0
onDeviceReady event should work.
Upvotes: 0