I'm using WL.Device.Geo.acquirePosition(onGeoLocationSuccess, onGeoLocationFailure, options) from MobileFirst to retrieve a device's location.
Initially, everything works smoothly as I successfully obtain the location.
However, after clearing the localStorage at a certain point in the application, things start acting up and an error keeps popping up in the console:
getPosition - error Attempt to invoke virtual method 'android.location.Location com.worklight.androidgap.plugin.WLGPSListener.getLastKnownLocation()' on a null object reference
Here's a snippet of my code:
position();
function position() {
var options = {
enableHighAccuracy : false,
timeout : 20000,
maximumAge : 30000,
highAccuracyOptions: {
desiredAccuracy: 50, //meters
iOSBestAccuracy: WL.Device.Geo.IOS_BEST_ACCURACY
}
};
WL.Device.Geo.acquirePosition(onGeoLocationSuccess, onGeoLocationFailure, options);
}
function onGeoLocationSuccess(position) {
WL.Logger.info('Got position now ;)');
}
function onGeoLocationFailure(errorObj) {
console.log('Trying again ');
position();
}
This is how I am resetting the localStorage in another service
localStorage.clear();
Any suggestions?