Exemplo n.º 1
0
  private void errorCallback(final String returnInfo) {
    if (geofencingCallbacks == null) {
      JSONObject returnErrorInfo = new JSONObject();
      try {
        returnErrorInfo.put("code", DGLocationStatus.PERMISSIONDENIED.getStatusCode());
        returnErrorInfo.put("message", "At first, Please call initCallbackForRegionMonitoring().");
      } catch (JSONException ex) {
        currentCallbacks.sendPluginResult(
            new PluginResult(PluginResult.Status.ERROR, ex.toString()));
        return;
      }

      currentCallbacks.sendPluginResult(
          new PluginResult(PluginResult.Status.ERROR, returnErrorInfo));
    } else {
      cordova
          .getThreadPool()
          .execute(
              new Runnable() {
                public void run() {

                  PluginResult result = new PluginResult(PluginResult.Status.ERROR, returnInfo);
                  result.setKeepCallback(true);
                  geofencingCallbacks.sendPluginResult(result);
                }
              });
    }
  }
Exemplo n.º 2
0
  private boolean checkGeofencingAvailable() throws JSONException {
    if (!isLocationServicesEnabled()) {
      JSONObject returnInfo = new JSONObject();
      returnInfo.put("code", DGLocationStatus.PERMISSIONDENIED.getStatusCode());
      returnInfo.put("message", "Location services are disabled.");

      errorCallback(returnInfo);

      if (currentCallbacks != null) {
        currentCallbacks.error(returnInfo);
      }

      return false;
    } else if (!isGooglePlayServicesAvailable()) {
      JSONObject returnInfo = new JSONObject();
      returnInfo.put("code", DGGeofencingStatus.GEOFENCINGUNAVAILABLE.getStatusCode());
      returnInfo.put("message", "Geofencing services are disabled.");

      errorCallback(returnInfo);

      if (currentCallbacks != null) {
        currentCallbacks.error(returnInfo);
      }

      return false;
    }

    return true;
  }