Screen

The Screen class includes several static utility methods for fullscreen and screen orientation, as well as methods to register listeners when the rotation changes, etc.

Static utility methods:

  • lockScreenOrientation() - This can be used to lock the screen to a specific orientation. Note: An element must be previously fillscreened before the screen can be locked.

  • unlockScreenOrientation() - This can unlock the screen again after a call to lockScreenOrientation().

  • fullscreenEnabled() - This can be used to check if the fullscreen mode is currently active.

  • getScreenOrientation() - This can be used to check which orientation the screen is currently in.

The remaining methods are there to fullscreen an element, as well as to register listeners for it in case the screen orientation changes, etc.

  • addScreenOrientationListener() - This listener is executed when the screen orientation has changed. With the returned registry this listener can be removed again.

  • addFullscreenErrorListener() - This listener is executed when fullscreening of an element failed.

  • addFullscreenExitErrorListener() - This listener is executed when exiting fullscreen mode failed.

  • requestFullscreen() - This method can be used to fullscreen the element passed in the constructor. exitFullscreen() - This can be used to exit the fullscreen mode.

  • unregisterAllScreenOrientationListeners() - This allows all registered listeners to be unregistered at once.

Example:

// We use this as parameter, in order to set the complete screen as fullscreen
final Screen screen = new Screen(this);
screen.requestFullscreen(FullscreenOptions.DEFAULT);