mirror of
https://github.com/apache/cordova-android.git
synced 2025-04-22 08:36:25 +08:00
GeoBroker checks if location service avialable for device first.
This commit is contained in:
parent
c52dc10c9e
commit
e575212c49
@ -59,9 +59,14 @@ public class GeoBroker extends Plugin {
|
|||||||
this.networkListener = new NetworkListener(this.locationManager, this);
|
this.networkListener = new NetworkListener(this.locationManager, this);
|
||||||
this.gpsListener = new GPSListener(this.locationManager, this);
|
this.gpsListener = new GPSListener(this.locationManager, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginResult.Status status = PluginResult.Status.NO_RESULT;
|
PluginResult.Status status = PluginResult.Status.NO_RESULT;
|
||||||
String message = "";
|
String message = "Location API is not available for this device.";
|
||||||
PluginResult result = new PluginResult(status, message);
|
PluginResult result = new PluginResult(status, message);
|
||||||
|
|
||||||
|
if ( locationManager.isProviderEnabled( LocationManager.GPS_PROVIDER ) ||
|
||||||
|
locationManager.isProviderEnabled( LocationManager.NETWORK_PROVIDER )) {
|
||||||
|
|
||||||
result.setKeepCallback(true);
|
result.setKeepCallback(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -88,7 +93,9 @@ public class GeoBroker extends Plugin {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
|
result = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearWatch(String id) {
|
private void clearWatch(String id) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user