I have found the following code to prevent the screen from rotating but when i compile i get a bunch of undeclared identifiers: IFMXScreenService, TPlatformServices.
Obviously this is because of missing units. But i cannot find what unit it 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 assistance would be great thank you.
Update:
The unit missing was FMX.Platform. But when i try to compile now, i get an error: \\android\\debug\\libproject.so: open: permission denied
Add FMX.Platform to your uses clause, and get rid of the redundant call to 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;
Go to Project Options -> Application -> Orientation
Check Custom Orientation and check one of the Landscape options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With