秋·风

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

The first step it's a run sample from RAD Studio that named SensorInfo on your device. On the tab Biometric you can see HumanProximity. If it's true you can get access to this sensor using RTL.

Add unit System.Sensors into uses list and drop TTimer

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    FHumanProximity: TCustomBiometricSensor; // Declare it
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.fmx}
 
procedure TForm1.FormCreate(Sender: TObject);
var
  LSensorArray : TSensorArray;
  LSensor : TCustomSensor;
begin // Get the sensor list and find that we want
  TSensorManager.Current.Activate();
  LSensorArray := TSensorManager.Current.GetSensorsByCategory(TSensorCategory.Biometric);
  for LSensor in LSensorArray do
    if TCustomBiometricSensor(LSensor).SensorType = TBiometricSensorType.HumanProximity then
      FHumanProximity := TCustomBiometricSensor(LSensor);
end;
 
procedure TForm1.Timer1Timer(Sender: TObject);
begin // just poll it
  if FHumanProximity <> nil then
    Label1.Text := FHumanProximity.HumanProximity.ToString;
end;
 
end.
posted on 2014-05-29 14:35  秋·风  阅读(624)  评论(0编辑  收藏  举报