I'm having a problem in my app that I never met before.I've been having this app for a while and runned it thousands of time, but I never got this error.
I have a server that receives some GPS data that are written also in a DB and a singleton class. In one of my classes I use an Async Task thread in order to read from the singleton class the new GPS data that arrived and display those points on the map.
And now suddenly I get error at a line like this:
mc.animateTo(p1);
where mc=mapView.getController();
This is how my code looks like:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mapView = (MapView) findViewById(R.id.mapview1);
mapView.setBuiltInZoomControls(true);
mc = mapView.getController();
mc.setZoom(17);
mapView.setSatellite(true);
mapView.setStreetView(true);
mapView.invalidate();
}
public class InitTask extends AsyncTask<Void, GeoPoint, Void> {
GeoPoint p;
protected Void doInBackground(Void... voids) {
try {
while (true) {
if(number.equals("Car1"))
{
longitude = ServerManager.getInstance().getLastLongitude1();
latitude = ServerManager.getInstance().getLastLatitude1();
speed = ServerManager.getInstance().getLastSpeed1();
loc1 = ServerManager.getInstance().getLastLocation1();
speed = ServerManager.getInstance().getLastSpeed1();
}
runOnUiThread(new Runnable() {
public void run() {
speed_1.setText(Integer.toString(speed));
location.setText(loc1);
}
});
p = new GeoPoint(latitude, longitude);
publishProgress(p);
Thread.sleep(1500);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
protected void onProgressUpdate(GeoPoint... progress1) {
theRouteDraw(progress1[0]);
}
This is how theRouteDraw() looks like:
public void theRouteDraw(GeoPoint p1) {
mc.animateTo(p1);
mc.setZoom(17);
mapView.setSatellite(true);
mapView.invalidate();
}
ServerManager is my singleton class...I read new data from there and use publishProgress(); and the method theRouteDraw() to display those points on the map.
I'm not using any overlay or special image on my map.
I get error in this method
public void theRouteDraw(GeoPoint p1) {
public void theRouteDraw(GeoPoint p1) {
mc.animateTo(p1);
mc.setZoom(17);
mapView.setSatellite(true);
mapView.invalidate();
}
at this line: mc.animateTo(p1);
This is my logcat:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
at com.google.android.maps.StreetViewRenderer.generateNewTileImage(StreetViewRenderer.java
at com.google.android.maps.StreetViewRenderer.renderTile(StreetViewRenderer.java:88)
at com.google.android.maps.AndroidTileOverlayRenderer.renderTile(AndroidTileOverlayRenderer.)
at com.google.googlenav.map.Map.drawTile(Unknown Source)
at com.google.googlenav.map.Map.drawMapBackground(Unknown Source)
at com.google.googlenav.map.Map.preLoad(Unknown Source)
at com.google.android.maps.MapController.animateTo(MapController.java:234)
at com.google.android.maps.MapController.animateTo(MapController.java:203)
at com.Server_1.Server4.theRouteDraw(Server4.java:159)