Antonio February 2016

Rebooted android phone and the Geolocation in my phonegap application stopped working

I rebooted my android phone and the geolocation code in my app has stopped working. The navigator.geolocation is returning true but getCurrentPosition and watchPosition aren't working. It isn't returning an error message either. I have location turned on the phone, the phone version is 5.0.1 and the cordova version I am using is 5.3.3.

Any help would be greatly appreciated!

The JavaScript code I am using:

function showCurrentPosition(){
    if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }
}


// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function(position) {
    alert('Latitude: '          + position.coords.latitude          + '\n' +
          'Longitude: '         + position.coords.longitude         + '\n' +
          'Altitude: '          + position.coords.altitude          + '\n' +
          'Accuracy: '          + position.coords.accuracy          + '\n' +
          'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '\n' +
          'Heading: '           + position.coords.heading           + '\n' +
          'Speed: '             + position.coords.speed             + '\n' +
          'Timestamp: '         + position.timestamp                + '\n');
};

// onError Callback receives a PositionError object
//
function onError() {
    alert('code: '    + error.code    + '\n' +
          'message: ' + error.message + '\n');
}

Console Log:

The key "target-densitydpi" is not supported.
file:///android_asset/www/css/images/ajax-loader.gif Failed to load resource: net::ERR_FILE_NOT_FOUND
whitelist.js:23 No Content-Security-Policy meta tag found. Please add one when using the cordova-plugin-whitelist plugin.(anonymous function) @ whitelist.js:23
index.js:41 Uncaught TypeError: Cannot read property 'querySelector' of null        

Answers


Antonio February 2016

I figured out what was causing my geolocation to stop working. When I rebooted my android is set the location services to GPS only. When I changed it use WiFi, phone network and GPS for my location it was able to obtain my longitude and latitude.

The problem with my android phone is that the GPS has stopped working so this turned out to be a hardware problem not a software problem.

Post Status

Asked in February 2016
Viewed 1,512 times
Voted 10
Answered 1 times

Search




Leave an answer