Step Detector and Step Counter Sensors on Android
Step Detector and Step Counter Sensors on Android
Android KitKat has added a few more hardware sensors to it's API list. Step Sensors are one of them, which looks very promising. Although, not a lot of phones yet have these Step Sensors, in the future, this would gradually become a standard I think. Currently, Nexus 5 has them.
Let's see how we can interact with these sensors. Basically, there are 2 sensors.
- Step Counter:
This keeps a count of the number of steps that you have taken. The
counter is only reset when you re-boot the device, else, for every step
you take (or the phone thinks you took, you counts up). - Step Detector:
This sensor just detects when you take a step. That's it.
The example project shows you how to initialize and setup the SensorManager
and respond to events from the Sensors.
// Step Counter
sManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
float steps = event.values[0];
textViewStepCounter.setText((int) steps + "");
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, sManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER),
SensorManager.SENSOR_DELAY_UI);
// Step Detector
sManager.registerListener(new SensorEventListener() {
@Override
public void onSensorChanged(SensorEvent event) {
// Time is in nanoseconds, convert to millis
timestamp = event.timestamp / 1000000;
}
@Override
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
}, sManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR),
SensorManager.SENSOR_DELAY_UI);
No special permissions are required.
Step Detector and Step Counter Sensors on Android的更多相关文章
- 问题:PyCharm调试方法Force Step over与step over的区别
Force Step over与step over的差别是,后者在执行到函数时,如果函数中设置了断点,会在该函数断点处暂停,等待进一步调试指令,而Force Step over不论函数中是否有断点,都 ...
- step over、step into、step into my code、step out、run to cursor
红 step over 跳过子函数 黄 step into 进入子函数 蓝 step into my code 不执行源码的子函数执行自己的 黑 step out 跳出当前函数 绿 run to cu ...
- Android 4.4 KitKat 新特性
New in Android 4.4 KitKat 本文是一个概览,关于KitKat,也即Android4.4的新东西,先是功能型的,之后是设计上的. 很多特性本文并没有提到,很多提到的特性也只是简短 ...
- OpenCV2:Mat属性type,depth,step
在OpenCV2中Mat类无疑使占据着核心地位的,前段时间初学OpenCV2时对Mat类有了个初步的了解,见OpenCV2:Mat初学.这几天试着用OpenCV2实现了图像缩小的两种算法:基于等间隔采 ...
- How to step through your code in chrome
By executing code one line or one function at a time, you can observe changes in the data and in the ...
- AWS Step Function Serverless Applications
Installing VS Components To follow along with this article, you must have an AWS account and install ...
- OpenCV__cv::Mat::step
step[0]是矩阵中一行元素的字节数 step[1]是矩阵中一个元素的字节数(elemSize) step1 = step / elemSize1,elemSize1是元素的每个通道所占的字节数 s ...
- SoapUI Pro Project Solution Collection-Test Step Object
Package com.eviware.soapui.model.testsuite used for access the current testsuite object, like test c ...
- OpenCV中对Mat里面depth,dims,channels,step,data,elemSize和数据地址计算的理解 (转)
cv::Matdepth/dims/channels/step/data/elemSizeThe class Mat represents an n-dimensional dense numeric ...
随机推荐
- Matplotlib安装感想
刚刚安装完numpy,看完书又涉及到matplotlib,哎,安装它浪费了我很多时间,但收获很多呀 下面介绍一下具体的安装过程: (1)http://matplotlib.org/downloads. ...
- Java 在方法和作用域内的内部类
通常,如果所读写 的代码包含了内部类,那么它们都是"平凡的"内部类,简单并且容易理解,然而,内部类的语法覆盖了大量其它的更加难以理解的计数,例如可以在一个方法里或者在任意的作用域里 ...
- Jupyter Notebook 入门
参考 Jupyter Notebook 快速入门 进阶 可看: Jupyter Notebook 的 27 个窍门,技巧和快捷键 Jupyter Notebook(此前被称为 IPython ...
- MySQL的lock tables和unlock tables的用法(转载)
早就听说lock tables和unlock tables这两个命令,从字面也大体知道,前者的作用是锁定表,后者的作用是解除锁定.但是具体如何用,怎么用,不太清楚.今天详细研究了下,总算搞明白了2者的 ...
- Mac 下的 .app文件如何生成.dmg ?
安装 Node.js最新版. 安装方法不赘述. 安装 create-dmg: sudo npm install --global create-dmg 注意这里 sudo不能少. 终端切换到 .app ...
- oracle 查询 约束
select * FROM all_constraints where CONSTRAINT_NAME='SYS_xxx'
- 面向对象设计原则 单一职责原则(Single responsibility principle)
单一职责原则(SRP:Single responsibility principle) 又称单一功能原则,面向对象的基本原则之一.它规定 一个类应该只有一个发生变化的原因. 该原则由罗伯特·C·马丁( ...
- iml文件
iml是 intellij idea的工程配置文件,里面是当前projec的一些配置信息 ==== android studio svn 汉化 常规. 描述.网络.安全的shell 壳. 用命令行 ...
- HEOI2018翻盘记
HEOI2018翻盘记 听说依照惯例要写一篇游记?好吧,没有退役,我已经谢天谢地了QAQ.那就用两句歌词做开头吧: "遠い遠い夢の終わり.悪夢に似た現実はもう昔日久远,梦之终结,那犹如噩梦的 ...
- https建立通讯过程及运行机制 [转]
ssl与tls: SSL:(Secure Socket Layer,安全套接字层),为Netscape所研发,用以保障在Internet上数据传输之安全,利用数据加密(Encryption)技术,可确 ...