Use the following method to check orientation changes.
public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height)
If the width is greater than the height, you know that the orientation has changed to landscape.
Make sure you now treat x as y and y as x. The same goes for width and height.
source share