Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 938
Mahesh Meniya Avatar asked Jan 17 '13 05:01

Mahesh Meniya


People also ask

How do I get location notifications?

Add a Location Sharing notificationIn the “Notifications” section, tap Add . Under “Choose a location,” select an address or click Add location . To choose a new location, enter an address in the search bar or click Choose on map. To set location, move your finger across the screen.

How do I turn on location sharing?

Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.


1 Answers

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.

like image 88
Keval Prabhu Avatar answered Sep 20 '22 10:09

Keval Prabhu