mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-26 20:33:07 +08:00
Fix a NPE in GeoBroker when there is no previous location.
This commit is contained in:
parent
e575212c49
commit
b297fe6f59
@ -75,7 +75,7 @@ public class GeoBroker extends Plugin {
|
|||||||
int maximumAge = args.getInt(1);
|
int maximumAge = args.getInt(1);
|
||||||
Location last = this.locationManager.getLastKnownLocation((enableHighAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER));
|
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
|
// 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));
|
result = new PluginResult(PluginResult.Status.OK, this.returnLocationJSON(last));
|
||||||
} else {
|
} else {
|
||||||
this.getCurrentLocation(callbackId, enableHighAccuracy);
|
this.getCurrentLocation(callbackId, enableHighAccuracy);
|
||||||
|
Loading…
Reference in New Issue
Block a user