如何prevent屏幕旋转与德尔福xe5 Firemonkey Android开发 [英] How to prevent screen rotation with android development in delphi xe5 Firemonkey
问题描述
我发现以下code至prevent屏幕旋转,但我编译时得到一堆未申报的标识符: IFMXScreenService,TPlatformServices
。
显然,这是因为缺少单位。但是,我找不到它是什么单位。
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.
更新:
单位缺少的是 FMX.Platform
。但是,当我现在尝试编译,我得到一个错误: \\\\ \\\\的Android调试\\\\ libproject.so:开:不准
The unit missing was FMX.Platform
. But when i try to compile now, i get an error: \\android\\debug\\libproject.so: open: permission denied
推荐答案
添加 FMX.Platform
你的使用
子句和摆脱冗余呼叫到 GetPlatformService()
:
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;
这篇关于如何prevent屏幕旋转与德尔福xe5 Firemonkey Android开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!