Fix a NPE in GeoBroker when there is no previous location.

This commit is contained in:
Andrew Grieve 2012-08-08 23:39:02 -04:00
parent e575212c49
commit b297fe6f59

View File

@ -75,7 +75,7 @@ public class GeoBroker extends Plugin {
int maximumAge = args.getInt(1);
Location last = this.locationManager.getLastKnownLocation((enableHighAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER));
// Check if we can use lastKnownLocation to get a quick reading and use less battery
if ((System.currentTimeMillis() - last.getTime()) <= maximumAge) {
if (last != null && (System.currentTimeMillis() - last.getTime()) <= maximumAge) {
result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last));
} else {
this.getCurrentLocation(callbackId, enableHighAccuracy);