• [转]xe6 android 使用距离传感器(Proximiry)


    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.
  • 相关阅读:
    这仅仅是一份工作
    和老总之间的对话
    假设满足怎样的条件,就不去编程
    那都是别人的架构
    程序员狂想曲
    学点经济学知识(三)
    一起来看 HTML 5.2 中新的原生元素 <dialog>
    动态配置页面 之 组件系统
    初识JavaScript EventLoop
    webpack+vue-cli+ElementUI+vue-resource 前端开发
  • 原文地址:https://www.cnblogs.com/qiufeng2014/p/3759093.html
Copyright © 2020-2023  润新知