Note that there are some explanatory texts on larger screens.

plurals
  1. POPointing current location in my android map
    text
    copied!<p>I am having my latitude and longitude in my android map. But when I tried to make a mark / point of my current location, the app crushes out without showing the result. Here is my code:</p> <pre><code> public void onLocationChanged(Location loc) { GeoPoint point = new GeoPoint( (int) (loc.getLatitude() * 1E6), (int) (loc.getLongitude() * 1E6)); String Text = "Latitude = " + loc.getLatitude() + "Longitude = " + loc.getLongitude(); Toast.makeText( getApplicationContext(),Text,Toast.LENGTH_SHORT).show(); mapcontroller.animateTo(point); mapcontroller.setZoom(16); MapOverlay mapOverlay = new MapOverlay(); mapOverlay.setPointToDraw(point); List&lt;Overlay&gt; listOfOverlays = mapView.getOverlays(); listOfOverlays.clear(); listOfOverlays.add(mapOverlay); } class MapOverlay extends Overlay { private GeoPoint pointToDraw; public void setPointToDraw(GeoPoint point) { pointToDraw = point; } public GeoPoint getPointToDraw() { return pointToDraw; } public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) { super.draw(canvas, mapView, shadow); // convert point to pixels Point screenPts = new Point(); mapView.getProjection().toPixels(pointToDraw, screenPts); // add marker Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.icon); canvas.drawBitmap(bmp, screenPts.x, screenPts.y - 24, null); return true; } } </code></pre> <p>My Logcat is:</p> <pre><code> 01-09 19:07:19.209: W/dalvikvm(293): threadid=1: spin on suspend resolved in 1043 msec 01-09 19:07:19.209: D/dalvikvm(293): Restored policy of 310 to 0 01-09 19:07:19.209: D/dalvikvm(293): Restored priority on 310 to 19 01-09 19:07:20.220: W/dalvikvm(293): threadid=1: spin on suspend #1 threadid=7 (pcf=0) 01-09 19:07:20.220: D/dalvikvm(293): Temporarily moving tid 309 to fg (was 0) 01-09 19:07:20.220: D/dalvikvm(293): Temporarily raised priority on tid 309 (19 -&gt; 0) 01-09 19:07:20.259: W/dalvikvm(293): threadid=1: spin on suspend resolved in 1043 msec 01-09 19:07:20.259: D/dalvikvm(293): Restored policy of 309 to 0 01-09 19:07:20.259: D/dalvikvm(293): Restored priority on 309 to 19 01-09 19:07:20.530: D/dalvikvm(293): GC_FOR_MALLOC freed 4877 objects / 301616 bytes in 2364ms 01-09 19:07:21.530: D/dalvikvm(293): GC_FOR_MALLOC freed 10081 objects / 613024 bytes in 329ms 01-09 19:07:22.460: D/dalvikvm(293): GC_FOR_MALLOC freed 4747 objects / 311336 bytes in 248ms 01-09 19:07:23.309: D/dalvikvm(293): GC_FOR_MALLOC freed 6145 objects / 374872 bytes in 233ms 01-09 19:07:24.340: D/dalvikvm(293): GC_FOR_MALLOC freed 8497 objects / 649704 bytes in 259ms 01-09 19:07:25.299: D/dalvikvm(293): GC_FOR_MALLOC freed 6086 objects / 370152 bytes in 293ms 01-09 19:07:25.969: I/MapActivity(293): Handling network change notification:CONNECTED 01-09 19:07:25.969: E/MapActivity(293): Couldn't get connection factory client 01-09 19:07:26.550: D/dalvikvm(293): GC_EXTERNAL_ALLOC freed 3698 objects / 326888 bytes in 303ms 01-09 19:07:26.990: D/dalvikvm(293): GC_FOR_MALLOC freed 270 objects / 112080 bytes in 220ms 01-09 19:07:27.299: D/dalvikvm(293): GC_FOR_MALLOC freed 3495 objects / 240288 bytes in 227ms 01-09 19:07:27.769: D/dalvikvm(293): GC_EXTERNAL_ALLOC freed 185 objects / 136920 bytes in 222ms </code></pre> <p>Can anybody suggest me if there is any error.</p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload