@Override public void onAddGeofencesResult(int i, String[] strings) { switch (i){ case LocationStatusCodes.SUCCESS: String geofences = ""; for (String string : strings) { geofences += string + ","; } break; default: Log.e(LOG_TAG, "Error adding Geofences. Status code: " + i); Toast.makeText(this, "Error adding geofences.", Toast.LENGTH_SHORT).show(); } mInProgress = false; mLocationClient.disconnect(); }
@Override public void onResult(Status status) { if(LocationStatusCodes.SUCCESS == status.getStatusCode()){ LOGD(TAG, "Geofences refreshed :)"); }else{ LOGE(TAG, "Geofences not refreshed: errorcode " + status.getStatusCode()); EasyTracker.getInstance(this).send(MapBuilder .createEvent("exception", "AddGeofence", "Geofences not refreshed: errorcode " + status.getStatusCode(), null) .build() ); } // disconnect from services if(servicesConnected()){ locationClient.disconnect(); } stopSelf(); }
@Override public void onAddGeofencesResult(int statusCode, String[] strings) { if (statusCode == LocationStatusCodes.SUCCESS) { Log.i(LOGGER_TAG, strings.length + " geofences registered successfully."); for (String reqId : strings) { GeofenceClient client = mGeofenceClients.get(reqId); if (client == null) Log.w(LOGGER_TAG, "Null client."); else client.onMonitoringStarted(); } } else { // TODO: Report error to user. } mNextOperation = GeofenceOperationType.NONE; mNextOperationClients.clear(); }
@Override public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent pendingIntent) { // Intent to be broadcasted with either success or failure message // attached. Intent broadcastIntent = new Intent(); if (statusCode == LocationStatusCodes.SUCCESS) { Log.d(Constants.APPTAG, context.getString(R.string.geofence_remove_success)); broadcastIntent.setAction(Constants.ACTION_GEOFENCES_REMOVED); } else { Log.e(Constants.APPTAG, context.getString(R.string.geofence_remove_error)); broadcastIntent.setAction(Constants.ACTION_GEOFENCES_REMOVE_ERROR); } LocalBroadcastManager.getInstance(context).sendBroadcast( broadcastIntent); requestDisconnection(); }
@Override public void onRemoveGeofencesByRequestIdsResult(int statusCode, String[] geofenceRequestIds) { // Intent to be broadcasted with either success or failure message // attached. Intent broadcastIntent = new Intent(); if (statusCode == LocationStatusCodes.SUCCESS) { Log.d(Constants.APPTAG, context.getString(R.string.geofence_remove_success)); broadcastIntent.setAction(Constants.ACTION_GEOFENCES_REMOVED); } else { Log.e(Constants.APPTAG, context.getString(R.string.geofence_remove_error)); broadcastIntent.setAction(Constants.ACTION_GEOFENCES_REMOVE_ERROR); } LocalBroadcastManager.getInstance(context).sendBroadcast( broadcastIntent); requestDisconnection(); }
@Override public void onAddGeofencesResult(final int statusCode, final String[] geofenceRequestIds) { if (mListener != null) { if (LocationStatusCodes.SUCCESS == statusCode) { Log.d(LOG_TAG, "Geofences ids added: " + Arrays.toString(geofenceRequestIds)); mListener.addGeofenceListener(mPlaceId); } else { Log.d(LOG_TAG, "Add geofences failed. Ids: " + Arrays.toString(geofenceRequestIds)); mListener.errorGeofenceListener(mPlaceId, mContext.getString(R.string.geofences_add_fails)); } } // Disconnect the location client requestDisconnection(); }
/** * When the request to remove geofences by PendingIntent returns, handle the * result. * * @param statusCode * the code returned by Location Services * @param requestIntent * The Intent used to request the removal. */ @Override public void onRemoveGeofencesByPendingIntentResult(final int statusCode, final PendingIntent requestIntent) { // If removing the geofences was successful if (statusCode == LocationStatusCodes.SUCCESS) { Log.d(LOG_TAG, "Remove geofences by pending intent"); mListener.removeGeofenceListener(mPlaceId, mAddType); } else { Log.e(LOG_TAG, "Removing geofences failed"); mListener.errorGeofenceListener(mPlaceId, mContext.getString(R.string.geofences_removed_fails, statusCode)); } // Disconnect the location client requestDisconnection(); }
/** * When the request to remove geofences by IDs returns, handle the result. * * @param statusCode * The code returned by Location Services * @param geofenceRequestIds * The IDs removed */ @Override public void onRemoveGeofencesByRequestIdsResult(final int statusCode, final String[] geofenceRequestIds) { // If removing the geocodes was successful if (LocationStatusCodes.SUCCESS == statusCode) { // Create a message containing all the geofence IDs removed. Log.d(LOG_TAG, "Removed the following ids: " + Arrays.toString(geofenceRequestIds)); mListener.removeGeofenceListener(mPlaceId, mAddType); } else { Log.e(LOG_TAG, "We had a problem (code): " + statusCode + "\nIds: " + Arrays.toString(geofenceRequestIds)); mListener.errorGeofenceListener(mPlaceId, mContext.getString(R.string.geofences_removed_fails)); } // Disconnect the location client requestDisconnection(); }
/** * Handle results of GeoFences' removal by PendingIntent. */ @Override public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent pendingIntent) { switch (statusCode) { case LocationStatusCodes.SUCCESS: System.out.println("DBG LocationOnlyService GeoFences removed"); break; case LocationStatusCodes.GEOFENCE_NOT_AVAILABLE: System.out.println("DBG LocationOnlyService GeoFence remove status: NOT_AVAILABLE"); break; case LocationStatusCodes.ERROR: System.out.println("DBG LocationOnlyService GeoFence remove status: ERROR"); break; } }
@Override public void onAddGeofencesResult(int status, String[] geofenceIds ) { if( status == LocationStatusCodes.SUCCESS ) { Intent intent = new Intent( mIntent ); startService( intent ); } }
/** * When the request to remove geofences by PendingIntent returns, handle the result. * * @param statusCode the code returned by Location Services * @param requestIntent The Intent used to request the removal. */ @Override public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent requestIntent) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // If removing the geofences was successful if (statusCode == LocationStatusCodes.SUCCESS) { // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, mContext.getString(R.string.remove_geofences_intent_success)); // Set the action and add the result message broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED); broadcastIntent.putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, mContext.getString(R.string.remove_geofences_intent_success)); // If removing the geocodes failed } else { // Always log the error Log.e(GeofenceUtils.APPTAG, mContext.getString(R.string.remove_geofences_intent_failure, statusCode)); // Set the action and add the result message broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR); broadcastIntent.putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, mContext.getString(R.string.remove_geofences_intent_failure, statusCode)); } // Broadcast the Intent to all components in this app LocalBroadcastManager.getInstance(mContext).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
public a(LocationClient.OnAddGeofencesResultListener paramInt, int paramArrayOfString, String[] arg4) { super(paramInt); this.mC = LocationStatusCodes.aR(paramArrayOfString); Object localObject; this.xY = localObject; }
public d(int paramOnRemoveGeofencesResultListener, LocationClient.OnRemoveGeofencesResultListener paramInt1, int paramPendingIntent, PendingIntent arg5) { super(paramInt1); boolean bool; if (paramOnRemoveGeofencesResultListener == 1) bool = true; else bool = false; ds.p(bool); this.yd = paramOnRemoveGeofencesResultListener; this.mC = LocationStatusCodes.aR(paramPendingIntent); Object localObject; this.mPendingIntent = localObject; this.xY = null; }
public d(int paramOnRemoveGeofencesResultListener, LocationClient.OnRemoveGeofencesResultListener paramInt1, int paramArrayOfString, String[] arg5) { super(paramInt1); boolean bool; if (paramOnRemoveGeofencesResultListener == 2) bool = true; else bool = false; ds.p(bool); this.yd = paramOnRemoveGeofencesResultListener; this.mC = LocationStatusCodes.aR(paramArrayOfString); Object localObject; this.xY = localObject; this.mPendingIntent = null; }
/** * When the request to remove geofences by PendingIntent returns, handle the result. * * @param statusCode the code returned by Location Services * @param requestIntent The Intent used to request the removal. */ @Override public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent requestIntent) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // If removing the geofences was successful if (statusCode == LocationStatusCodes.SUCCESS) { // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, context.getString(R.string.remove_geofences_intent_success)); // Set the action and add the result message broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED); broadcastIntent.putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, context.getString(R.string.remove_geofences_intent_success)); // If removing the geocodes failed } else { // Always log the error Log.e(GeofenceUtils.APPTAG, context.getString(R.string.remove_geofences_intent_failure, statusCode)); // Set the action and add the result message broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR); broadcastIntent.putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, context.getString(R.string.remove_geofences_intent_failure, statusCode)); } // Broadcast the Intent to all components in this app LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
/** * Called when request to add geofences is complete, with a result status code. */ @Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { // Log if adding the geofences was successful. if (LocationStatusCodes.SUCCESS == statusCode) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Added geofences successfully."); } } else { Log.e(TAG, "Failed to add geofences. Status code: " + statusCode); } // Turn off the in progress flag and disconnect the client. mInProgress = false; mLocationClient.disconnect(); }
@Override public void onRemoveGeofencesByRequestIdsResult(int i, String[] strings) { switch (i){ case LocationStatusCodes.SUCCESS: String geofences = ""; for (String string : strings) { geofences += string + ","; } break; default: Log.e(LOG_TAG, "Error removing Geofences. Status code: " + i); Toast.makeText(this, "Error removing geofences.", Toast.LENGTH_SHORT).show(); } }
@Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { Log.d(GeoAlarmUtils.APPTAG, "AddGeofencesResult"); if (statusCode == LocationStatusCodes.SUCCESS) { Log.d(GeoAlarmUtils.APPTAG, "AddGeofencesResult Success!!!"); } else { Log.d(GeoAlarmUtils.APPTAG, "AddGeofencesResult Error!!!"); } }
@Override public void onRemoveGeofencesByRequestIdsResult(int statusCode, String[] geofenceIds) { Log.d(GeoAlarmUtils.APPTAG, "RemoveGeofencesByRequestIdsResult"); if (statusCode == LocationStatusCodes.SUCCESS) { Log.d(GeoAlarmUtils.APPTAG, "RemoveGeofencesByRequestIdsResult Success!!!"); } else { Log.d(GeoAlarmUtils.APPTAG, "RemoveGeofencesByRequestIdsResult Error!!!"); } }
@Override public void onRemoveGeofencesByPendingIntentResult(int statusCode, PendingIntent pendingIntent) { // If removing the geofences was successful if (statusCode == LocationStatusCodes.SUCCESS) { // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, "Removing all geofences succeeded."); } else { // Always log the error Log.e( TAG, String.format("Removing all geofences failed: error code %1$d", statusCode)); } // Disconnect locationClient.disconnect(); }
/** * Callback for results from adding GeoFences. */ @Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { System.out.println("DBG: addGeofences status code: " + statusCode); switch (statusCode) { case LocationStatusCodes.SUCCESS: break; case LocationStatusCodes.GEOFENCE_NOT_AVAILABLE: sendErrorAndExit("Error: likely some Android settings prevented usage"); break; case LocationStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES: sendErrorAndExit("Error: too many GeoFences"); break; case LocationStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS: sendErrorAndExit("Error: too many PendingIntents"); break; default: sendErrorAndExit("Error: unknown GeoFence error"); break; } StringBuffer dbgBuf = new StringBuffer(); for (int i = 0; i < geofenceRequestIds.length; i++) { dbgBuf.append(" "); dbgBuf.append(geofenceRequestIds[i]); } String dbg = dbgBuf.toString(); System.out.println("DBG GeoFences added: " + dbg); }
private String statusCodeToString(int statusCode) { switch (statusCode) { case LocationStatusCodes.SUCCESS: return "SUCCESS"; case LocationStatusCodes.GEOFENCE_NOT_AVAILABLE: return "GEOFENCE_NOT_AVAILABLE"; case LocationStatusCodes.GEOFENCE_TOO_MANY_GEOFENCES: return "GEOFENCE_TOO_MANY_GEOFENCES"; case LocationStatusCodes.GEOFENCE_TOO_MANY_PENDING_INTENTS: return "GEOFENCE_TOO_MANY_PENDING_INTENTS"; case LocationStatusCodes.ERROR: return "ERROR"; } return "UNKNOWN"; }
@Override public void onRemoveGeofencesByRequestIdsResult(int status, String[] strings) { if( status == LocationStatusCodes.SUCCESS ) { stopService( mIntent ); } }
@Override public void onRemoveGeofencesByPendingIntentResult(int status, PendingIntent pendingIntent) { if( status == LocationStatusCodes.SUCCESS ) { stopService( mIntent ); } }
@Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // Temp storage for messages String msg; // If adding the geocodes was successful if (LocationStatusCodes.SUCCESS == statusCode) { // Create a message containing all the geofence IDs added. msg = mActivity.getString(R.string.add_geofences_result_success, Arrays.toString(geofenceRequestIds)); // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_ADDED) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); // If adding the geofences failed } else { /* * Create a message containing the error code and the list * of geofence IDs you tried to add */ msg = mActivity.getString( R.string.add_geofences_result_failure, statusCode, Arrays.toString(geofenceRequestIds) ); // Log an error Log.e(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } // Broadcast whichever result occurred LocalBroadcastManager.getInstance(mActivity).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
/** * When the request to remove geofences by IDs returns, handle the result. * * @param statusCode The code returned by Location Services * @param geofenceRequestIds The IDs removed */ @Override public void onRemoveGeofencesByRequestIdsResult(int statusCode, String[] geofenceRequestIds) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // Temp storage for messages String msg; // If removing the geocodes was successful if (LocationStatusCodes.SUCCESS == statusCode) { // Create a message containing all the geofence IDs removed. msg = mContext.getString(R.string.remove_geofences_id_success, Arrays.toString(geofenceRequestIds)); // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } else { // If removing the geocodes failed /* * Create a message containing the error code and the list * of geofence IDs you tried to remove */ msg = mContext.getString( R.string.remove_geofences_id_failure, statusCode, Arrays.toString(geofenceRequestIds) ); // Log an error Log.e(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } // Broadcast whichever result occurred LocalBroadcastManager.getInstance(mContext).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
@Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // Temp storage for messages String msg; // If adding the geocodes was successful if (LocationStatusCodes.SUCCESS == statusCode) { // Create a message containing all the geofence IDs added. msg = activity.getString(R.string.add_geofences_result_success, Arrays.toString(geofenceRequestIds)); // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_ADDED) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); // If adding the geofences failed } else { /* * Create a message containing the error code and the list * of geofence IDs you tried to add */ msg = activity.getString( R.string.add_geofences_result_failure, statusCode, Arrays.toString(geofenceRequestIds) ); // Log an error Log.e(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } // Broadcast whichever result occurred LocalBroadcastManager.getInstance(activity).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
/** * When the request to remove geofences by IDs returns, handle the result. * * @param statusCode The code returned by Location Services * @param geofenceRequestIds The IDs removed */ @Override public void onRemoveGeofencesByRequestIdsResult(int statusCode, String[] geofenceRequestIds) { // Create a broadcast Intent that notifies other components of success or failure Intent broadcastIntent = new Intent(); // Temp storage for messages String msg; // If removing the geocodes was successful if (LocationStatusCodes.SUCCESS == statusCode) { // Create a message containing all the geofence IDs removed. msg = context.getString(R.string.remove_geofences_id_success, Arrays.toString(geofenceRequestIds)); // In debug mode, log the result Log.d(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCES_REMOVED) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } else { // If removing the geocodes failed /* * Create a message containing the error code and the list * of geofence IDs you tried to remove */ msg = context.getString( R.string.remove_geofences_id_failure, statusCode, Arrays.toString(geofenceRequestIds) ); // Log an error Log.e(GeofenceUtils.APPTAG, msg); // Create an Intent to broadcast to the app broadcastIntent.setAction(GeofenceUtils.ACTION_GEOFENCE_ERROR) .addCategory(GeofenceUtils.CATEGORY_LOCATION_SERVICES) .putExtra(GeofenceUtils.EXTRA_GEOFENCE_STATUS, msg); } // Broadcast whichever result occurred LocalBroadcastManager.getInstance(context).sendBroadcast(broadcastIntent); // Disconnect the location client requestDisconnection(); }
@Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { if (LocationStatusCodes.SUCCESS == statusCode) Log.i(TAG, "Geofences set"); else Log.e(TAG, "Geofences where not set correctly, errorCode" + statusCode); }
@Override public void onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) { // Intent to be broadcasted with either success or failure message // attached. Intent broadcast = new Intent(); if (LocationStatusCodes.SUCCESS == statusCode) { Log.d(Constants.APPTAG, context.getString(R.string.geofence_add_success)); broadcast.setAction(Constants.ACTION_GEOFENCES_ADDED); } else { Log.e(Constants.APPTAG, context.getString(R.string.geofence_add_error)); broadcast.setAction(Constants.ACTION_GEOFENCES_ADD_ERROR); } LocalBroadcastManager.getInstance(context).sendBroadcast(broadcast); requestDisconnection(); }