Reputation: 2737
How can I use proximity alerts on my Google Maps activity? This proximity alerts are located within a certain radius that I already specified earlier.
public class GeoUpdateHandler implements LocationListener
{
public void onLocationChanged(Location location)
{
// TODO Auto-generated method stub
int lat = (int)(location.getLatitude() * 1E6);
int lng = (int)(location.getLongitude() * 1E6);
GeoPoint point = new GeoPoint(lat, lng);
mapController.animateTo(point); // mapController.setCenter(point)
}
}
Upvotes: 2
Views: 4253
Reputation: 2747
This is the code I used for setting proximity alert on my app:
LocationManager lm=(LocationManager) getSystemService(LOCATION_SERVICE);
lm.addProximityAlert(latitude, longitude, radius, expiration, intent);
Upvotes: -1
Reputation: 29438
Since you haven't provided any line of code it's really difficult to suggest you anything else than reading the following tutorial: Android Proximity Alerts Tutorial.
The key part of it is the LocationManager.addProximityAlert() method, which
Sets a proximity alert for the location given by the position (latitude, longitude) and the given radius. When the device detects that it has entered or exited the area surrounding the location, the given PendingIntent will be used to create an Intent to be fired.
Upvotes: 2