Oddly, the function getHeight() still return the 144px of the non fullscreen mode. I need to calculate the yOffset to center the screen content for devices with different screen height (eg. Sony Ericsson 220px).
Is there any possibility to get the real screen height in fullscreen mode? I heard about some kind of hardware profiles, but didn't find any functions which support them.
I would not recommend using sleep() in this way, as it is highly non-portable. The correct way is to use the sizeChanged() event as Alexander writes.
Alternatively, getHeight() in the paint() method every time it is called.
The problem comes from the fact that the Canvas does not change height immediately, but at some future point. You must wait for an appropriate event (such as sizeChanged() or paint()) before checking getHeight().