Zoom to Bounding Box

Hey Guys,

im a new osmdroid developer and try to zoom automatically to a GeoObject, but nothing happens. I can set zoomLevel and center manually. But i am drawing Polygonys, reading from a GeoJson File and i want to zoom automatically to that polygon. I have look everywhere but i could not find any solution.

Here is a snippet of my code:


BoundingBox boundingBox = new BoundingBox(getLatNorth(), getLatSouth(), getLongWest());
map.getController().setCenter(boundingBox.getCenter());
map.zoomToBoundingBox(boundingBox, false);

I have seen somewhere that you should not use that in the onCreate Method of the Activity, is it true? I hope someone can help me out, because it gets really annoying.

Thanks
Kind regards

Cenk