[
https://issues.apache.org/jira/browse/CB-3023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13634314#comment-13634314
]
Jack Piccininni commented on CB-3023:
-------------------------------------
Joe,
It working on your Xoom and not on my mine doesn't mean the issue doesn't
exist. I am running a sample mini-app on a Droid3 and a Xoom tablet, and
getting different results (Xoom = fail, Droid3 = pass). Both devices can track
my position with Google Maps.
Here's the sample code (and maybe you can share your sample code so I can try
it):
// index.html:
<!DOCTYPE html>
<html>
<head>
<title>Geolocation Tester</title>
<meta name="viewport" content="width=device-width,
initial-scale=1, user-scalable=no" />
<meta charset="utf-8" />
<style type="text/css">
#messageDiv { font-size:8pt; font-family:courier}
</style>
<script type="text/javascript" charset="utf-8"
src="cordova-2.5.0.js"></script>
<script type="text/javascript" charset="utf-8"
src="TMMobileMain.js"></script>
</head>
<body onload="onBodyLoad()">
<b>Geolocation Tester</b>
<div id="messageDiv"></div>
</body>
</html>
// TMMobileMain.js:
var PhoneGapReady = false;
var receivedFirstOnlineOfflineStatus = false;
var lastReportedOnlineEvent = false;
var messageDiv;
var counter = 0;
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
document.addEventListener("online", OnlineFired, false);
document.addEventListener("offline", OfflineFired, false);
console.log("onBodyLoad");
messageDiv = document.getElementById("messageDiv");
messageDiv.innerHTML += "<br>onBodyLoad<br>";
}
function onDeviceReady()
{
console.log("onDeviceReady");
messageDiv.innerHTML += "onDeviceReady<br>";
PhoneGapReady = true;
if (receivedFirstOnlineOfflineStatus)
Initialize();
}
function OnlineFired() {
console.log("OnlineFired");
messageDiv.innerHTML += "OnlineFired<br>";
receivedFirstOnlineOfflineStatus = true;
lastReportedOnlineEvent = true;
if (PhoneGapReady)
Initialize();
}
function OfflineFired() {
console.log("OfflineFired");
messageDiv.innerHTML += "OfflineFired<br>";
receivedFirstOnlineOfflineStatus = true;
lastReportedOnlineEvent = false;
if (PhoneGapReady)
Initialize();
}
function Initialize() {
console.log("Initialize");
messageDiv.innerHTML += "Initialize<br>";
navigator.geolocation.getCurrentPosition(onGetFollowMeSuccess,
onGetFollowMeError, { maximumAge: 5000, timeout: 15000, enableHighAccuracy:
false });
navigator.geolocation.watchPosition(onWatchSuccess, onWatchError, {
maximumAge: 5000, timeout: 20000, enableHighAccuracy: false });
}
function onGetFollowMeSuccess(position) {
counter++;
var now = new Date();
var message = "GetCurrent success #: " + counter + ", " +
now.getHours() + ":" + (now.getMinutes() < 10? "0" + now.getMinutes():
now.getMinutes()) + ":" + (now.getSeconds() < 10? "0" + now.getSeconds():
now.getSeconds()) + ", Lat: " + position.coords.latitude + ", Long: " +
position.coords.longitude;
console.log(message);
messageDiv.innerHTML += message + "<br>";
}
function onGetFollowMeError(error) {
counter++;
var now = new Date();
var message = "GetCurrent Error: #" + counter + ", " + now.getHours()
+ ":" + (now.getMinutes() < 10? "0" + now.getMinutes(): now.getMinutes()) +
":" + (now.getSeconds() < 10? "0" + now.getSeconds(): now.getSeconds()) + "
Message: " + error.message;
console.log(message);
messageDiv.innerHTML += message + "<br>";
}
function onWatchSuccess(position) {
counter++;
var now = new Date();
var message = "Watch success #: " + counter + ", " + now.getHours() +
":" + (now.getMinutes() < 10? "0" + now.getMinutes(): now.getMinutes()) + ":"
+ (now.getSeconds() < 10? "0" + now.getSeconds(): now.getSeconds()) + ", Lat: "
+ position.coords.latitude + ", Long: " + position.coords.longitude;
console.log(message);
messageDiv.innerHTML += message + "<br>";
}
function onWatchError(error) {
counter++;
var now = new Date();
var message = "Watch Error: #" + counter + ", " + now.getHours() + ":"
+ (now.getMinutes() < 10? "0" + now.getMinutes(): now.getMinutes()) + ":" +
(now.getSeconds() < 10? "0" + now.getSeconds(): now.getSeconds()) + " Message:
" + error.message;
console.log(message);
messageDiv.innerHTML += message + "<br>";
}
> Geolocation API does not work on Motorola Xoom tablet (and perhaps/probably
> other devices)
> ------------------------------------------------------------------------------------------
>
> Key: CB-3023
> URL: https://issues.apache.org/jira/browse/CB-3023
> Project: Apache Cordova
> Issue Type: Bug
> Components: Android
> Affects Versions: 2.3.0, 2.4.0, 2.5.0
> Environment: Mac OS X 10.8.3, Eclipse 4.2.1, Cordova 2.5.0, Motorola
> Xoom tablet running Android v4.1.2
> Reporter: Jack Piccininni
> Assignee: Joe Bowser
> Priority: Minor
> Labels: Geolocation, Xoom,
>
> In a nutshell: the Geolocation API does not work on the Xoom tablet. The
> "success" callback never gets called after getCurrentPosition() or
> watchPosition().
> More details... Neither the:
> - navigator.geolocation.getCurrentPosition(onSuccess, onError, { maximumAge:
> 2000, timeout: 5000, enableHighAccuracy: true }) nor
> - navigator.geolocation.watchPosition(onSuccess, onError, { maximumAge: 2000,
> timeout: 5000, enableHighAccuracy: true })
> methods result in the "onSuccess" callback being called.
> Without the optional options ("{ maximumAge: 2000, timeout: 5000,
> enableHighAccuracy: true }") included in the methods, the "onError" callback
> never (unless the default timeout is several minutes, if there is a default)
> gets called either. With the options included, it does, and the timeout error
> (error.message = "Timeout expired") is generated. Only the onError callback
> gets called, never the onSuccess callback, when running on the Xoom.
> Tested on other devices (Droid3 and iPhone) and these methods work (though
> watchPosition is slow on Droid3, another bug). Manifest and inspection of
> permissions look correct. Xoom is able to show its location using other apps
> like Google Maps.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira