Android实例-MotionSensor加速度(XE8+小米2)

时间:2021-12-31 15:18:42

Android实例-MotionSensor加速度(XE8+小米2)

结果:

1.

实例代码:

 unit Unit1;

 interface

 uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Sensors,
FMX.StdCtrls, FMX.Controls.Presentation, System.Sensors.Components; type
TForm1 = class(TForm)
MotionSensor1: TMotionSensor;
Switch1: TSwitch;
Label1: TLabel;
Timer1: TTimer;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
procedure Switch1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} procedure TForm1.FormCreate(Sender: TObject);
begin
Timer1.Enabled := False;
end; procedure TForm1.Switch1Click(Sender: TObject);
begin
MotionSensor1.Active := Switch1.IsChecked;
Timer1.Enabled := Switch1.IsChecked;
end; procedure TForm1.Timer1Timer(Sender: TObject);
var
LProp: TCustomMotionSensor.TProperty;//所有可能得到的参数
begin
for LProp in MotionSensor1.Sensor.AvailableProperties do//开始循环,如果手机支持该参数则显示出来
begin
case LProp of
TCustomMotionSensor.TProperty.AccelerationX:
begin
Label10.Visible := True;
Label10.Text := Format('Acceleration X: %6.2f', [MotionSensor1.Sensor.AccelerationX]);
end;
TCustomMotionSensor.TProperty.AccelerationY:
begin
Label11.Visible := True;
Label11.Text := Format('Acceleration Y: %6.2f', [MotionSensor1.Sensor.AccelerationY]);
end;
TCustomMotionSensor.TProperty.AccelerationZ:
begin
Label12.Visible := True;
Label12.Text := Format('Acceleration Z: %6.2f', [MotionSensor1.Sensor.AccelerationZ]);
end;
TCustomMotionSensor.TProperty.AngleAccelX:
begin
Label13.Visible := True;
Label13.Text := Format('Angle X: %6.2f', [MotionSensor1.Sensor.AngleAccelX]);
end;
TCustomMotionSensor.TProperty.AngleAccelY:
begin
Label14.Visible := True;
Label14.Text := Format('Angle Y: %6.2f', [MotionSensor1.Sensor.AngleAccelY]);
end;
TCustomMotionSensor.TProperty.AngleAccelZ:
begin
Label15.Visible := True;
Label15.Text := Format('Angle Z: %6.2f', [MotionSensor1.Sensor.AngleAccelZ]);
end;
TCustomMotionSensor.TProperty.Motion:
begin
Label16.Visible := True;
Label16.Text := Format('Motion: %6.2f', [MotionSensor1.Sensor.Motion]);
end;
TCustomMotionSensor.TProperty.Speed:
begin
Label17.Visible := True;
Label17.Text := Format('Speed: %6.2f', [MotionSensor1.Sensor.Speed]);
end;
end;
end;
end; end.

Android实例-MotionSensor加速度(XE8+小米2)的更多相关文章

  1. Android实例-操作摄像头(XE8+小米2)

    结果: 1.同样是照相,自己的程序设置为高质量时刷新慢,而小米手机的相机那真心反映快呀. 2.就算我设置为最高质量,可相片也没有小米手机的相片大.我最大是2000*1000,而小米可以做到3000*2 ...

  2. Android实例-手机震动(XE8+小米2)

    相关资料:http://blog.csdn.net/laorenshen/article/details/41148843 结果: 1.打开Vibrate权限为True. 2.规律震动我没感觉出来,有 ...

  3. Android实例-LocationSensor位置传感器(XE8+小米2)

    结果: 1.启动后有时会闪退,后来重新做的工程就好了.原因不明(可能与地理反码有关). 2.原文是用的GOOGLE地图显示位置,但在咱们这里好像不行,改为百度,但百度用的是HTML文件.太麻烦了,大家 ...

  4. Android实例-消息框(XE8+小米2)

    方法一支持. 方法二与方法三都是三方单元,功能相同. 方法4与方法5报错,提示平台不支持. 第三方单元一: unit Android.JNI.Toast; // Java bridge class i ...

  5. Android实例-实现扫描二维码并生成二维码(XE8+小米5)

    相关资料: 第三方资料太大没法写在博文上,请下载CSDN的程序包. 程序包下载: http://download.csdn.net/detail/zhujianqiangqq/9657186 注意事项 ...

  6. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...

  7. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)

    相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...

  8. 45个android实例源码

    分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...

  9. 分享45个android实例源码,很好很强大

    分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...

随机推荐

  1. 《Objiect》

    [16-1]Object概述&Object-equals方法&toString方法. ================================================= ...

  2. boa安装

    Boa 下载地址:http://www.boa.org/boa-0.94.13.tar.gz 1.解压生成Makefile tar xzf boa-0.94.13.tar.gz #解压 cd boa- ...

  3. Android ListView快速定位(二)

    方法二:android:textFilterEnabled="true" + Filter 这个属性在android.widget.AbsListView下,要求adapter必须 ...

  4. CentOS 7 安装 Apache PHP MariaDB

    准备篇: 一.配置防火墙,开启80端口.3306端口 CentOS 7 默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl sto ...

  5. node.js(八) 有趣的东西才开始哦

    ### Express介绍 npm提供了大量的第三方模块,其中不乏许多Web框架,比如我们本章节要讲述的一个轻量级的Web框架 ——— Express. Express是一个简洁.灵活的node.js ...

  6. Android学习路线(六)为Android应用加入ActionBar

    Action bar 是你可以为你的应用的Activity实现的最为重要的设计元素之中的一个.它提供了集中UI特性.而且通过提供和其它的Android应用的一致性体验让你的应用可以非常快被用户熟悉.基 ...

  7. Git工具的使用教程

    Git 是一种版本控制工具,也叫作版本管理软件(分布式管理软件).这里介绍Git的基本使用步骤,关于 Git 更详细的介绍,读者可以参考其官方网站提供的文档. 1  安装Git 在Ubuntu系统中安 ...

  8. DDGScreenShot —图片加各种滤镜高逼格操作

    写在前面 图片加各种滤镜操作,当然苹果给开发者提供了相关的api和封装, 大部分开发者感觉这是这是晦涩难懂的,接下来就让我们来了解一下, 其实也没有那么深不可测. 代码如下(每一步已经解释的很详细) ...

  9. IntelliJ IDEA下的使用git

    1.git简介 git是目前流行的分布式版本管理系统.它拥有两套版本库,本地库和远程库,在不进行合并和删除之类的操作时这两套版本库互不影响.也因此其近乎所有的操作都是本地执行,所以在断网的情况下任然可 ...

  10. 关于mysql文件导入提示“Variable @OLD_CHARACTER_SET_CLIENT can't be set to the value of @@CHARACTER_SET_CLIENT”问题分析

    今天用myssqldump导出数据,然后再导入另外mysql数据库时,提示Variable @OLD_CHARACTER_SET_CLIENT can't be set to the value of ...