I have to make an android application with the purpose of a user check-in on a bus. The app have to research the beacons from a bus and at the same time has to send a beacon. How can I check that the received beacon is a beacon that last 2 minutes, in order to understand that the user is actually on the bus and he's not passing by?
As a starting point, I'm using https://github.com/Jaosrikate/iBeacon-Android and I'm trying to make some changes. Do you have any suggestions on how to do this?
Beacon ranging involves a callback from the API that gives you a beacon identifier. The time of the callback is the time the beacon was detected.
The basic algorithm is simple:
Create a HashMap<String,Date> to store the timestamp of the first time a beacon was detected. Use a string representation of the beacon identifier as the key.
Whenever a beacon is detected, check to see if it’s identifier is already in the map.
If the identifier is not in the map, store it along with the current Date()
If the identifier is in the map, check to see if the current time - the stored time in the map > 2 minutes. If so, you have a match