Best way to instantly check proximity to one of two locations in Android? -
i'm writing app utilizes parse cloud data storage. told people i'm writing opening second location, , know location user checking in to/recording data at. i've found google code at: http://developer.android.com/training/location/geofencing.html
that defines how use geofencing, how last known gps/network location.
http://developer.android.com/guide/topics/location/strategies.html
but can't tell if either 1 of these need. i'm trying following:
- user starts app
- user clicks "check in" check in class @ gym
- when "check in" activity loads, user can click class. @ point in time i'd know if user say...within 5 miles of central lat/long. 2 locations around 20 miles apart, rough estimate putting them within few miles should fine (are in sunnyvale or san jose?)
- when user clicks class, check-in gets sent parse database, along location (either 1 city or other)
i'm not sure if geofencing proper case, need know rough area point..but basic location getting sample doesn't seem show how check when phone near point.
to point, i've found following: http://www.javacodegeeks.com/2011/01/android-proximity-alerts-tutorial.html
this seems best option, except checks "distance" set point, , need tell once if user near 1 or other locations.
something maybe:
location me = new location(""); location dest = new location(""); me.setlatitude(mylat); me.setlongitude(mylong); dest.setlatitude(destlat); dest.setlongitude(destlong); float dist = me.distanceto(dest);
you can repeat second location , store both distances compare see smallest.
Comments
Post a Comment