本文介绍了如何在后台或睡眠模式采样加速度计数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个计划,将采样加速计数据所有的时间,做了一些分析。但我发现,当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.
的developer.android/reference/android/os/PowerManager.html#PARTIAL_WAKE_LOCK
更多推荐
如何在后台或睡眠模式采样加速度计数据
发布评论