Mahesh Meniya
Mahesh Meniya

Reputation: 2605

Android : Get notification when user enter in specific location

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.

Upvotes: 20

Views: 21009

Answers (3)

Fuad All
Fuad All

Reputation: 975

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.

Upvotes: 1

Keval Prabhu
Keval Prabhu

Reputation: 1030

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.

Upvotes: 20

Gabe Sechan
Gabe Sechan

Reputation: 93569

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

Upvotes: 7

Related Questions