如何在后台或睡眠模式采样加速度计数据 [英] How to sample accelerometer data in the background or on the sleep mode

查看:292
本文介绍了如何在后台或睡眠模式采样加速度计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个计划,将采样加速计数据所有的时间,做了一些分析。但我发现,当pressing电源按钮或在睡眠模式下,系统不会在一段时间后采样数据。是否有人知道如何让加速度运行在后台收集数据?

I have a program which will sample accelerometer data all the time and do some analysis. But I find that when pressing the power button or in the sleep mode, the system will not sample data after a period of time. Does anybody know how to let accelerometer run in the background to collect data?

非常感谢!

推荐答案

您需要设置一个PARTIAL_WAKE_LOCK将保持CPU运行,仍然允许在屏幕熄灭。当然,电池会更快耗尽。

You'll need to set a PARTIAL_WAKE_LOCK which will keep the CPU running and still allow the screen to go off. Of course, the battery will run down faster.

http://developer.android.com/reference/android/os/PowerManager.html#PARTIAL_WAKE_LOCK

这篇关于如何在后台或睡眠模式采样加速度计数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆