Hello.

I need my application to perform a function when changing the geolocation of a smartphone. For example, we set a specific point on the map, indicated a radius, and it is necessary that when a smartphone hits this area, an information message is displayed to the user in the notification line. In this case, the function should work during sleep mode.

I understand that you need to use a Broatcast receiver with something?

    2 answers 2

    Using Geofence from Google Play Services is easy to implement.

    Post on Habré

    Description on developer.android.com

      You can create geofences and watch user actions. For example, to add a geofence:

      mGeofenceList.add(new Geofence.Builder() // Set the request ID of the geofence. This is a string to identify this // geofence. .setRequestId(entry.getKey()) .setCircularRegion( entry.getValue().latitude, entry.getValue().longitude, Constants.GEOFENCE_RADIUS_IN_METERS ) .setExpirationDuration(Constants.GEOFENCE_EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build()); 
      • It is not entirely clear, can you please give answers? - Vitaliy Sivolotskiy