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 ...
随机推荐
- Laravel中服务提供者和门面模式
在laravel中,我们可能需要用到自己添加的类时,可以建立一个文件夹专门存放类文件,也可以使用laravel的服务提供者的方式来使用. 这两者其实区别不大,主要是前者使用的话,会跟业务代码产生依赖, ...
- SCU 4438:Censor
Censor frog is now a editor to censor so-called sensitive words (敏感词). She has a long text p . Her j ...
- ERP渠道文档详细和修改(二十五)
前端代码: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChannelD ...
- 《jquery实战》javascript 必知必会(2)
A2 一等公民函数 在传统 OO 语言里,对象包含数据和方法.这些语言里,数据和方法通常是不同的概念:javascript另辟蹊径. 与其他 js 的类型一样,函数可以作为对象处理,如String.N ...
- P1616 疯狂的采药 洛谷
题目描述 LiYuxiang是个天资聪颖的孩子,他的梦想是成为世界上最伟大的医师.为此,他想拜附近最有威望的医师为师.医师为了判断他的资质,给他出了一个难题.医师把他带到一个到处都是草药的山洞里对他说 ...
- 几种常见类的使用(System,Runtime,Math,Date,Calendar,Random)
一:System 1.介绍 System:类中的方法和属性都是静态的. out:标准输出,默认是控制台. in:标准输入,默认是键盘. 2.properties 获取系统属性信息:Properties ...
- Linux环境Tomcat运行报错java.lang.OutOfMemoryError
java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "http-bio-8080-ex ...
- JAVA 传递
其实java里面都是传值,只不过基本数据类型传的是数值,而引用类型传的是对象的地址. 作者:Intopass链接:https://www.zhihu.com/question/31203609/ans ...
- 领英Linkedin信息搜集工具InSpy
领英Linkedin信息搜集工具InSpy 领英Linkedin是一个知名职业社交媒体网站.通过该网站,渗透测试人员可以获取公司内部组成和员工信息.Kali Linux提供一款专用的信息收集工具I ...
- zoj 3204 最小生成树,输出字典序最小的解
注意排序即可 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring ...