20

I am developing android application which gives notification when user enter in specific location
User can specify the location by using latitude longitude(ie Google Map)
I know how to get latitude & longitude but my problem is that when user enter in specific location then it will not exactly match with previously specified latitude & longitude. enter image description here

As shown in image suppose user specify the location called "My Place" when user enter in area (about 20 meter) then application should send notification to user.
I want know how I can compare the latitude & longitude which user specified(My place) and current latitude & longitude which application fetch by GPS. The comparison made in such way that it will true if user near by of My place in area of 20 meter. (This 20 meters is approximate.) Can I set accuracy of in android e.g. 20 meters.
Thank you.

Mahesh Meniya
  • 2,627
  • 3
  • 18
  • 17

3 Answers3

20

The best approach to this problem is using the GeoFences feature. Please refer to https://developer.android.com/training/location/geofencing.html for more details.

Outline: - The application registers with the underlying OS - saying - here is MY list of geofences (specific location + radius from the location) that I want you to monitor. - If my user comes within this geo fence - wake me up and tell me so. - At that point of time - you can go ahead and perform any step (either call a server and ask what information you need to display to the user) or just send a push notification (in app notification) to do the necessary work.

Hope this helps.

Keval Prabhu
  • 990
  • 8
  • 10
7

Look at the LocationManager.addProximityAlert function. It does pretty much exactly what you want. Warning, it does use a good amount of battery.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Is there any better solution which require less amount of batter power? Thanks... – Mahesh Meniya Jan 17 '13 at 06:14
  • 1
    Not really. Basically, you'd need to do what it does- check every time the gps location updates, and see if you're within the range by doing a distance check between your location and the target. The power is used because you need GPS constantly on when doing this. Just make sure to remove the alert when you don't need it. – Gabe Sechan Jan 17 '13 at 06:16
  • So you are saying that Instendof using addProximityAlert() I should should check the distance by using lat. and lon. of specific location and current location.Am I getting right or any thing else? – Mahesh Meniya Jan 17 '13 at 06:31
1

You can make gps pooling calculating with spatial distance functions

There is point sdk (android & ios) from Bluedotinnovation which has more accuracy and less battery drain also similar free sdk from Radar

Radar geofencing is more powerful than native iOS or Android geofencing, with cross-platform support for unlimited geofences, polygon geofences, stop detection, and accuracy down to 30 meters.

Also they have ReactNative support.

ItamarG3
  • 4,092
  • 6
  • 31
  • 44
Fuad All
  • 871
  • 11
  • 13