How to prevent screen rotation with the development of android in delphi xe5 Firemonkey

I found the following code to prevent rotation of the screen, but when I compile, I get a bunch of undeclared identifiers IFMXScreenService, TPlatformServices. Obviously, this is due to missing units. But I can’t find what this unit is.

code:

procedure TLogin.FormCreate(Sender: TObject);
var
  ScreenService: IFMXScreenService;
  OrientSet: TScreenOrientations;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService) then
  begin
    ScreenService := TPlatformServices.Current.GetPlatformService
      (IFMXScreenService) as IFMXScreenService;
    OrientSet := [TScreenOrientation.soLandscape];
    ScreenService.SetScreenOrientation(OrientSet);
  end;
end;

Any help would be greatly appreciated.

Update:

The lack of a device was FMX.Platform. But when I try to compile now, I get an error message:\\android\\debug\\libproject.so: open: permission denied

+2
source share
2 answers

Add FMX.Platformto your offer usesand get rid of the redundant call GetPlatformService():

uses
  ..., FMX.Platform;

procedure TLogin.FormCreate(Sender: TObject);
var
  ScreenService: IFMXScreenService;
  OrientSet: TScreenOrientations;
begin
  if TPlatformServices.Current.SupportsPlatformService(IFMXScreenService, IInterface(ScreenService)) then
  begin
    OrientSet := [TScreenOrientation.soLandscape];
    ScreenService.SetScreenOrientation(OrientSet);
  end;
end;
+3
source

" " → "" → ""

.

+1

Source: https://habr.com/ru/post/1613461/


All Articles