GeoBroker checks if location service avialable for device first.

This commit is contained in:
Evgeni Petrov 2012-08-08 11:23:08 +03:00 committed by Andrew Grieve
parent c52dc10c9e
commit e575212c49

View File

@ -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) {