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)的更多相关文章
- Android实例-操作摄像头(XE8+小米2)
结果: 1.同样是照相,自己的程序设置为高质量时刷新慢,而小米手机的相机那真心反映快呀. 2.就算我设置为最高质量,可相片也没有小米手机的相片大.我最大是2000*1000,而小米可以做到3000*2 ...
- Android实例-手机震动(XE8+小米2)
相关资料:http://blog.csdn.net/laorenshen/article/details/41148843 结果: 1.打开Vibrate权限为True. 2.规律震动我没感觉出来,有 ...
- Android实例-LocationSensor位置传感器(XE8+小米2)
结果: 1.启动后有时会闪退,后来重新做的工程就好了.原因不明(可能与地理反码有关). 2.原文是用的GOOGLE地图显示位置,但在咱们这里好像不行,改为百度,但百度用的是HTML文件.太麻烦了,大家 ...
- Android实例-消息框(XE8+小米2)
方法一支持. 方法二与方法三都是三方单元,功能相同. 方法4与方法5报错,提示平台不支持. 第三方单元一: unit Android.JNI.Toast; // Java bridge class i ...
- Android实例-实现扫描二维码并生成二维码(XE8+小米5)
相关资料: 第三方资料太大没法写在博文上,请下载CSDN的程序包. 程序包下载: http://download.csdn.net/detail/zhujianqiangqq/9657186 注意事项 ...
- Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)
注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...
- Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)
相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...
- 45个android实例源码
分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...
- 分享45个android实例源码,很好很强大
分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...
随机推荐
- DJANGO技巧两则:模拟MKDIR -P及配合NGINX上传大文件不使超时
这都是在开发当哪遇到的问题,网上转转,作个记录: http://blog.chinaunix.net/uid-25525723-id-1596574.html http://bookshadow.co ...
- android 64位的so文件 报错
问题解决了,原因是因为豌豆荚搞了个64位的so文件,然后其他用到so的就必须也要有64位的,把他们的64位的so文件删除了,就OK了...
- ANDROID_MARS学习笔记_S01_012_RatingBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- Android:android:gravity 和 android:layout_Gravity 的区别
LinearLayout有两个非常相似的属性:android:gravity与android:layout_gravity. android:gravity 属性是对该view中内容的限定 andro ...
- oracle connect by 和start with
网上找了个例子 测试了一下 貌似明白了create table t2(root_id number,id number,name varchar(5),description varchar(10)) ...
- 数据关联分析 association analysis (Aprior算法,python代码)
1基本概念 购物篮事务(market basket transaction),如下表,表中每一行对应一个事务,包含唯一标识TID,和购买的商品集合.本文介绍一种成为关联分析(association a ...
- python函数--传参
一.位置参数 二.关键字参数 三.默认参数 四.任意数量的位置参数: 1. *x 2. 传入的多个参数,最终合并成一个元组 3. 之后的参数必须用关键字参数 五.任意数量的关键字参数 1. **x 2 ...
- poj 1850 code(组合数学)
题目:http://poj.org/problem?id=1850 题意:按给定的规则给字母编号. 一个很简单的题目,但是却做了好久.................................. ...
- 解决项目中EF5.0升级到EF6.0无法安装包的方法
今天在vs2012上新建了一个mvc4的项目,mvc4中默认的Entity Framework是5.0的版本,如下所示: 或者:,但是项目中有些要用到EF6.0的相关方法,用EF5.0实在繁琐,于是在 ...
- UVa 1644 (筛素数 + 二分) Prime Gap
题意: 给出一个整数n,如果n是素数输出0,否则输出它后一个素数与前一个素数的差值. 分析: 首先用筛法把前十万个素数都筛出来,然后放到数组里.用二分找到不大于n的最大的素数的下标,如果这个素数等于n ...