Android: How to get a user to create geofences for other monitored users?

How to implement Geofence to track other users?
I am developing an application that will track family members, and I want to implement a Geofence function that will allow the user to do this: user A will track user B
user A will determine the geofuntation zone and when user B logs into this geopotency user, A will receive a notification

I deleted the location of user B every 10 minutes, and I want to create a Geofence for user B, which will notify user A when user B enters the geography area

I am trying to use Google Geofence like this code:

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()); 

but it just works for the user device "user location" is not for another user location.

+1
source share
1 answer

I think you should add a database and keep track of who created the geofence for whom. Also store the geocentric radius and center point in the database. To check if the user is within the geoforum, calculate the distance from the coordinates of the user's location and all geology coordinates, and then compare the distance with the radius in 5 minutes. If the distance is <radius, the user is inside the outside. If the user is set inside a flag to avoid repeated notifications. If user goes beyond reset, flag. I think this should work.

+2
source

Source: https://habr.com/ru/post/1012330/


All Articles