我正在尝试基于 GPS tat 实现警报,如果我在城市 x 并且当我到达那个特定的精确点时,我会在那个地方放置一个针点,它应该给我一个警报或警报我已经实现了一个完整的地图结构,我也有编程用于显示我当前的位置并用于定位。我不知道如何附加源代码,请以这种方式帮助我,我对 android 真的很陌生,我不知道该怎么做。这是代码,请指导我哪里出错了。
public void onLocationChanged(Location l)
{
// TODO Auto-generated method stub
lat=(int) (l.getLatitude() *1E6) ;
longi=(int) (l.getLongitude() *1E6);
ourLocation= new GeoPoint(lat,longi);
OverlayItem overlayItem= new OverlayItem(ourLocation,"","");
CustomPinpoint custom=new CustomPinpoint(d,Main.this);
custom.insertPinPoint(overlayItem);
overlayList.add(custom);
controller.setCenter(ourLocation);
geocoder= new Geocoder(getBaseContext(), Locale.getDefault());
try
{
List<Address>address1=geocoder.getFromLocation
(ourLocation.getLatitudeE6()/1E6,ourLocation .getLongitudeE6()/1E6, 1);
if(address1.size()>0 )
{
for(int i=0; i<address1.get(0).getMaxAddressLineIndex();i++)
{
display1 += address1.get(0).getAddressLine(i)+"\n";
}
}
}
catch(IOException e1)
{
e1.printStackTrace();
Toast.makeText(getBaseContext(), "error", Toast.LENGTH_LONG).show();
}
if(display1.equals(display))
{
AlertDialog alert= new AlertDialog.Builder(Main.this).create();
alert.setTitle("Destination");
alert.setMessage("You Reached to destination");
alert.setButton("OK",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
// TODO Auto-generated method stub
}
});
alert.show();
}
}