problem with onKeyDown
<p>My aim here is that I want this <code>Activity</code> to be able to move around and show the toasts while the user navigates the map, but as soon as he hits the center key, it should return the last value that the user touched.</p>

<p>Its not working for some reason, and when I put <code>onKeyDown</code> inside the if loop, it gives errors. How do I get it to work?</p>

<pre><code>    public class createNote extends MapActivity {

    MapView mapview;
    String sLatt;
    String sLonn;

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }       

    @Override
    public void onCreate(Bundle savedInstanceStates){       
        super.onCreate(savedInstanceStates);
        setContentView(R.layout.map);

        mapview=(MapView)findViewById(R.id.MapView);
        mapview.setBuiltInZoomControls(true);

        mapOverlay mapoverlay=new mapOverlay();
        List&lt;Overlay&gt;listOfOverlays=mapview.getOverlays();
        listOfOverlays.add(mapoverlay);


    }   


    class mapOverlay extends com.google.android.maps.Overlay{
        @Override

        public boolean onTouchEvent(MotionEvent event, MapView mapview){
            GeoPoint p=null;

            if (event.getAction()==1){
                 p=mapview.getProjection().fromPixels((int)event.getX(), (int)event.getY());
                Toast.makeText(getBaseContext(),p.getLatitudeE6()/1E6 + "," + p.getLongitudeE6()/1E6, Toast.LENGTH_SHORT).show();



            double lat=(double) (p.getLatitudeE6()/1E6);
            double lon=(double) (p.getLongitudeE6()/1E6);

            String sLat=Double.toString(lat);
            String sLon=Double.toString(lon);
            sLatt=sLat;
            sLonn=sLon;

            Toast.makeText(getBaseContext(),sLat + "-" + sLon,Toast.LENGTH_SHORT).show();


            //setResult(RESULT_OK, new Intent().setAction(sLat + "," + sLon));
            //setResult(RESULT_OK, new Intent().setAction("test"));
            //Intent data = new Intent();
            //data.putExtra("key1", sLat);
            //data.putExtra("key2", sLon);
            //setResult(RESULT_OK,data);
            //finish();



            }



            return false;
        }

        public boolean onKeyDown(int keyCode, KeyEvent event){
             super.onKeyDown(keyCode, event, mapview);
             if(keyCode==KeyEvent.KEYCODE_DPAD_CENTER){
                    Intent data = new Intent();
                    data.putExtra("key1", sLatt);
                    data.putExtra("key2", sLonn);
                    setResult(RESULT_OK,data);
                    finish();
                    return true;
             }
             else return false;

        }
    }


}
</code></pre>
