Hey TreKing,

If you dont mind, just refer this code.
You exactly got what is going on here. I am new in Android so I dont know
what is stack trace and log? How to check stack trace?

So here is my code.

public class ShowLocation extends MapActivity {
private EditText lat;
private EditText lng;
 GeoPoint gp=null;
 MapController  mapcontroller;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn = (Button)findViewById(R.id.btnShow);
        lat = (EditText)findViewById(R.id.lat);
        lng = (EditText)findViewById(R.id.lng);

        MapView mapView = (MapView)findViewById(R.id.myGMap);

        mapcontroller = mapView.getController();

        //gp = new GeoPoint(lat.intValue(), lng.intValue());
        mapView.setSatellite(true);
        mapView.setTraffic(true);
        mapView.setStreetView(true);
        mapView.displayZoomControls(true);
        mapView.setBuiltInZoomControls(true);

        //mapcontroller.animateTo(gp);
        mapcontroller.setZoom(2);
        LocationManager locationManager;
        String context = Context.LOCATION_SERVICE;
        locationManager = (LocationManager)getSystemService(context);

        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(true);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_HIGH);
        String provider = locationManager.getBestProvider(criteria, true);

     Location location = locationManager.getLastKnownLocation(provider);

        btn.setOnClickListener(new View.OnClickListener() {
 @Override
public void onClick(View v) {
// TODO Auto-generated method stub
String _lat = lat.getText().toString();
String _lng = lng.getText().toString();
Uri uri = Uri.parse("geo:"+_lat+","+_lng);
 startActivity(new Intent(Intent.ACTION_VIEW, uri));
//mapcontroller.animateTo(gp);
mapcontroller.setZoom(2);
}
});
        String _lat,_lng;
        MapOverlay mylocationoverlay = new MapOverlay();
        List<Overlay> list = mapView.getOverlays();
        list.add(mylocationoverlay);
    }
 protected class MapOverlay extends com.google.android.maps.Overlay{
 public boolean draw(Canvas canvas, MapView myGMap, boolean shadow, long
when){
Paint paint = new Paint();
//mapcontroller.animateTo(gp);
super.draw(canvas, myGMap, shadow);
 Point myScreenCoords = new Point();
//mapview.getProjection().toPixels(gp, myScreenCoords);
//paint.setARGB(255, 255, 255, 255);
Drawable marker = getResources().getDrawable(R.drawable.marker);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),
R.drawable.marker);
canvas.drawBitmap(bitmap, myScreenCoords.x, myScreenCoords.y, paint);
canvas.drawText("Location is at here..", myScreenCoords.x, myScreenCoords.y,
paint);
return true;
}
}
 @Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

~Dhr


On Wed, Sep 15, 2010 at 11:17 PM, TreKing <treking...@gmail.com> wrote:

> On Wed, Sep 15, 2010 at 12:42 PM, Dhrumil Shah <dhrumilsh...@gmail.com>wrote:
>
>> You can change this at any time.
>> - Ya, i know that thing, but its not working in my this application.
>>
>
> "It's not working" is not useful information.
>
>
>> Or you can animate or snap to the exact location.
>> - I used this method but it generates and force close error on my
>> emulator.
>>
>
> Did you check the stack trace?
>
>
>> Why not?
>> -I dont know why not. I try to debug it but it gives me nothing.
>>
>
> Nothing? No logs, no stack trace?
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to