- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
重力加速度传感器Sensor ACCELEROMETER
一 介绍Sensor类表示一个感应器的类,可以使用getSensorList方法(此方法属于接下来要讲的SensorManager)获得所有可用的感应器,该方法返回的是一个ListSensor下面的列表显示了,Sensorint?TYPE_ACCELEROMETER?A constant describing an accelerometer sensor type.
//三轴加速度感应器 返回三个坐标轴的加速度??单位m/s2int?TYPE_ALL??A constant describing all sensor type.
//用于列出所有感应器int?TYPE_GRAVITY??A constant describing a gravity sensor type.?//重力感应器
int?TYPE_GYROSCOPE?A constant describing a gyroscope sensor type?
//陀螺仪 可判断方向 返回三个坐标轴上的角度
int?TYPE_LIGHT?A constant describing an light sensor type.? //光线感应器 单位 lux 勒克斯
int?TYPE_LINEAR_ACCELERATION?A constant describing a linear acceleration sensor type.
//线性加速度
int?TYPE_MAGNETIC_FIELD? A constant describing a magnetic field sensor type.??//磁场感应 返回三个坐标轴的数值??微特斯拉
int?TYPE_ORIENTATION??This constant is deprecated. use SensorManager.getOrientation() instead.
//方向感应器 已过时 可以使用方法获得
int?TYPE_PRESSURE?A constant describing a pressure sensor type//压力感应器??单位 千帕斯卡
int?TYPE_PROXIMITY?A constant describing an proximity sensor type.?//距离传感器
int?TYPE_ROTATION_VECTOR?A constant describing a rotation vector sensor type.//翻转传感器
int?TYPE_TEMPERATURE?A constant describing a temperature sensor type//温度传感器 单位 摄氏度sensor类一般不需要new而是通过SensorManager的方法获得二 介绍SensorManager类SensorManager 允许你访问设备的感应器。通过传入参数SENSOR_SERVICE参数调用Context.getSystemService方法可以获得一个sensor的实例。永远记得确保当你不需要的时候,特别是Activity暂定的时候,要关闭感应器。忽略这一点肯能导致几个小时就耗尽电池,注意当屏幕关闭时,系统不会自动关闭感应器。三 加速度可以通过这个感应器获得三个浮点型
x-axis
y-axis
z-axis
插图分析次数据
2011110609092196.gif (10.95 KB, 下载次数: 55)
下载附件 ?保存到相册
2011-11-6 19:10 上传
X Y Z分别对应values[0]到[2]
X表示左右移动的加速度
Y表示前后移动的加速度
Z表示垂直方向的加速度 (测试时发现,将手机置于水平桌面稳定后 XY均为0Z的值为9.4 约等于重力加速度)
下面先看一个基本的获取加速的demo,希望大家好好注意代码中的注释
/*
2??* @author octobershiner
3??* 2011 07 27
4??* SE.HIT
5??* 一个演示android加速度感应器的例子
6??* */
7
8 package uni.sensor;
10 import java.util.Iterator;
11 import java.util.List;
13 import android.app.Activity;
14 import android.content.Context;
15 import android.hardware.Sensor;
16 import android.hardware.SensorEvent;
17 import an
您可能关注的文档
最近下载
- 2.2探秘传感器技术+课件-2024—2025学年上海科教版(2024版)初中信息技术八年级上册.pptx VIP
- 职业健康检查质控计划实施方案.docx VIP
- GB 50038-2005(2023年版) 人民防空地下室设计规范.docx
- 冀教版一年级数学上册我上学了《1认识新朋友》课件.pptx
- 泽天 EM-5烟气分析仪用户手册 2015-5-20.pdf VIP
- 精益思想与精益生产.ppt VIP
- 2022版 电力建设土建工程施工、试验及验收标准表式(第1部分 施工).doc
- 《感染性休克》ppt课件.pptx VIP
- 2025年高级工具钳工(三级)技能认定理论考试题库(含答案).docx VIP
- 肿瘤靶向治疗的新药研发进展.pptx VIP
文档评论(0)