Reputation: 167
I am retrieving the location of a device by using WL.Device.Geo.acquirePosition(onGeoLocationSuccess, onGeoLocationFailure, options), provided by MobileFirst.
The first time is works fine. I get the location and everything is ok.
However, at a point in the application I clear the localStorage. When I do so, the app goes crazy and I keep getting this error in the console:
getPosition - error Attempt to invoke virtual method 'android.location.Location com.worklight.androidgap.plugin.WLGPSListener.getLastKnownLocation()' on a null object reference
This is how my code looks like:
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?
Upvotes: 0
Views: 81
Reputation: 44516
Check for the contents of the localStorage; Since you are force-clearing the entire storage, I suspect you are clearing required data during an application's runtime.
Only clear what you need clearing, not all of it.
Upvotes: 2