Let's say , I have three classes : MapsActivity , MyItemizedOverlay & GetDirectionActivity . In MyItemizedOverlay , I want to switch to GetDirectionActivity after the positive dialog button is clicked . ActiveDialog is placed under onTap method , so that I can get the GeoPoint. For this , what I've done :
In ItemizedOverlay class :
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
// TODO Auto-generated method stub
int lat = p.getLatitudeE6();
int lot = p.getLongitudeE6();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
dialog.setTitle("Confirmation");
dialog.setMessage("Confirm this as end point ?");
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(mContext, GetDestination.class);
startActivity(intent);
}
});
dialog.setNegativeButton("No", null);
dialog.show();
return true ;
}
here IDE shows that I have a error in startActivity(intent) line .
I've tried that also :
In MyItemizedOverlay class :
@Override
public boolean onTap(GeoPoint p, MapView mapView) {
return super.onTap(p, mapView); }
In MapsActivity class :
GeoPoint point2 = null ;
confirmationOverlay.onTap(point2, mapView) ;
int latt = point.getLatitudeE6() ;
int longt = point.getLongitudeE6();
final int endpointArray [] = {latt , longt};
if(some condition to show the alert dialog after tapping)
{
AlertDialog.Builder dialog = new AlertDialog.Builder(MapsActivity.this);
dialog.setTitle("Confirmation");
dialog.setMessage("Confirm this location as end point ?");
dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
// TODO Auto-generated method stub
Intent intent = new Intent(MapsActivity.this,GetDestination.class);
intent.putExtra("geopoint" , endpointArray);
startActivity(intent);
}
});
dialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int arg1) {
}
});
dialog.show();
}
For the if statement what sort of condition I can use ? If I set it just like lat0 then the alertdialog appears without tapping on the map.
I know this is very silly , but since I am new in both android & java , I hope you guys will consider it. Please help !