当遇到 if 语句时,我想发出警报并使用对话框按钮将其关闭。
googleMap.setOnInfoWindowClickListener(
new OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker) {
LatLng clickedMarkerLatLng = marker.getPosition();
lat = clickedMarkerLatLng.latitude;
long1 = clickedMarkerLatLng.longitude;
String name = marker.getTitle();
select=true;
final Location markerLoc = new Location("");
markerLoc.setLatitude(lat);
markerLoc.setLongitude(long1);
final Location location = locationManager.getLastKnownLocation(provider);
float distanceBetweenPoints = location.distanceTo(markerLoc);
TextView t = (TextView) findViewById(R.id.tv_location);
t.setText("Distance to "+ name +" is "+ distanceBetweenPoints/1000 + " km");
if (distanceBetweenPoints<1000){
TextView t2 = (TextView) findViewById(R.id.tv_location);
t2.setText("ALARMALARMALARM");
//alarm here
}
});
我发现的有关警报管理器的所有内容似乎都不允许我在 if 语句中使用它。我该怎么做呢?