首页 > 解决方案 > Delphi 和 Android:OrientationSensor 没有倾斜信息

问题描述

在使用 Delphi 10.2 开发的多设备应用程序中,我刚刚创建了一个空表单并放入TOrientationSensor.

TOrientationSensor确实有倾斜属性:

OrientationSensor1.Sensor.TiltX 
OrientationSensor1.Sensor.TiltY
OrientationSensor1.Sensor.TiltZ

但是当被查询时,他们返回了一个带有 NAN 值的双精度值。

为了了解发生了什么,我放下了一个按钮和一个备忘录,并设法显示了OrientationSensor1.Sensor.AvailableProperties. 代码如下所示。

我得到的只是:

HeadingX
HeadingY
HEadingZ

所以 TiltX/Y/Z 不可用。怎么会这样?也许我必须在设备级别启用某些东西?

我在 moto g6 plus 上对其进行了测试;安卓版本为 8.0.0。

procedure TForm2.Button1Click(Sender: TObject);
var
    properties: TCustomOrientationSensor.TProperties;
    prop: TCustomOrientationSensor.TProperty;
begin

OrientationSensor1.Active := true;

properties := OrientationSensor1.Sensor.AvailableProperties;

for prop in properties do begin
   Memo1.Lines.Add(TRttiEnumerationType.GetName(prop));
end;

end;

标签: androiddelphiandroid-sensors

解决方案


推荐阅读