Make a call to setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); to get the app displayed in landscape mode, and setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); to switch to portrait mode.
To detect the current screen orientation that has been set by the application, here's how you do it:
int LOrientation = getRequestedOrientation();if (LOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {} ...
if (LOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) { } ...
To detect the current screen orientation without having called getRequestedOrientation before, call getResources().getConfiguration().orientation. The value of orientation will be one of the ActivityInfo.SCREEN_ORIENTATION_xxx values (SCREEN_ORIENTATION_LANDSCAPE, SCREEN_ORIENTATION_PORTRAIT, SCREEN_ORIENTATION_SQUARE).
To get the requested screen orientation, call getRequestedOrientation.If the application did not request a screen orientation before, it returns -1.
In 2017, with the release of Delphi 10.2 Tokyo, Embarcadero introduced a specialized implementation of the Observer pattern into the System.Classes unit. While it has been in the wild for 9 years, it remains a "hidden" architecture for many, primarily because it serves as the invisible engine behind LiveBindings. Other than live bindings, you can also use the Observer pattern as a way to update component settings to the Windows registry, an .ini file, or persist it elsewhere.
System.Classes