I am showing an alert when a user exits a certain area:
/*Function to show alert when Geofence breached*/
private void showAlert() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Geofence Breached");
builder.setMessage("User has breached the Geofence Boundary!");
builder.setPositiveButton(android.R.string.ok, null);
builder.show();
}
And I am calling it like so:
if( distance[0] > mCircle.getRadius() ){
showAlert();
}
Is there any way to set it that an alert only goes off every 2 minutes as the location is getting checked all the time then the notification keeps appearing. I have read about, Timers, Timertasks and alarmManagers but I dont think it will work for me. Any help would be appreciated.