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 ...
随机推荐
- bzoj 1143
求最长反链裸题 补充一点知识.. 链 : D 中的一个子集 C 满足 C 是全序集 及C中所有元素都可以比较大小 反链 : ...
- 【Java】 大话数据结构(11) 查找算法(2)(二叉排序树/二叉搜索树)
本文根据<大话数据结构>一书,实现了Java版的二叉排序树/二叉搜索树. 二叉排序树介绍 在上篇博客中,顺序表的插入和删除效率还可以,但查找效率很低:而有序线性表中,可以使用折半.插值.斐 ...
- sonarQube代码管理工具
第一步:安装环境:jdk 1.8 idea mysql5.6以上 sonarqube5.6.6 第二歩:下载好sonarqube后,解压打开bin目录,启动相应OS目录下的StartSonar ...
- ZOJ Monthly, March 2018 题解
[题目链接] A. ZOJ 4004 - Easy Number Game 首先肯定是选择值最小的 $2*m$ 进行操作,这些数在操作的时候每次取一个最大的和最小的相乘是最优的. #include & ...
- ajax jqplot ssh实现图表的持续更新
实现功能: 数据库有新数据图表会更新到 数据库查询使用ssh框架中的hibernate 想法: 画图表的ajaxautoruncopy.jsp利用ajax收到7-13.jsp传过来的数据 7-13.j ...
- odoo 工作流
odoo工作流 介绍 新版本的odoo开始减少workflow的使用,推荐使用workflow-ish的方式来处理工作流过程 很多模块中还是使用到工作流,这里我记录一个简单的实例,欢迎大家给出建议. ...
- Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录
0.目录 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 一.感谢 在此感谢.net ...
- Xamarin-Android_BaseAdapter 简单的复用
Xamarin-Android_BaseAdapter 简单的复用 缘由: 本人是一枚 小菜 初学Xamarin-Android 正在学习ListView 控件 发现这个控件的自定义布局 用的那叫一 ...
- 一个页面从输入URL 到页面加载显示完成,这个过程中都发生了什么?
1.当发送一个URL请求时,浏览器会开启一个线程来处理这个请求,同时在远程DNS服务器上启动一个DNS查询,解析获取网址的IP地址:2.浏览器与远程Web服务器通过TCP三次握手协商来建立一个TCP/ ...
- SQL2008配置管理工具服务显示远程过程调用失败
问题: 打开SQL2008配置管理工具,发现SQL服务名称里什么也没有,只有一个提示: 解决办法: 这是由于电脑中安装有Visual Stuido, 它内含一个本地SQL数据库服务:Microso ...