在Android的后台传感器数据采集器 [英] A background sensor data collector in Android

查看:534
本文介绍了在Android的后台传感器数据采集器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在编写一个程序,收集传感器数据,例如: acclerometer值了一整天。

I am now programming a program that collects sensor data, e.g. acclerometer values for a whole day.

目前我只用一个活动,并运行了一整天的活动(我关掉屏幕自动黑色),白天不作任何shortmessages或电话。

Current I just use an Activity and run the activity for a whole day (I turn off screen auto-black), and don't make any shortmessages or phone calls during the day.

我听说我可以使用服务做出这种长时间运行的数据采集器在后台。但我在 HTTP检查了计步器后://$c$c.google.com / P /计步器/ 。我发现,当屏幕黑了,计步器不工作。 (但是,像predometer应用程序应该在任何情况下工作,只要电源打开。)

I've heard I can make this kind of long running data collector in background using Service. But after I've checked the pedometer at http://code.google.com/p/pedometer/. I found that, when the screen blacks out, the pedometer does not work. (But An application like predometer should work in any case as long as the power is on.)

虽然我不关心的始终传感acclerometers电源问题,我想黑掉屏幕,以节省电能屏幕录制更多acclerometer数据点

Although I don't care about the power problem of always sensing acclerometers, I do want to black out the screen to save the power in screen to record more acclerometer data points.

我正在考虑两种方式:

1,使用一个服务,然而,随着计步器应用表明。当屏幕黑了,该服务似乎采空工作压力太大!也许code的错误。

1.Using an Service, however, as the pedometer application showed. When the screen blacks out, the service seems stoped working too! Maybe the code has bugs.

2.My应用程序仍然是一个活动。但我改变scrren光成0或全黑,以节省电力。

2.My application is still an Activity. But I change the scrren light into 0 or totally black to save power.

我的问题是:1)没有服务有abality总是被即使在运行时,屏幕黑了很长一段时间;对于2,如何改变屏幕的光?

My question is that: for 1) does a Service have the abality to be always running even when the screen blacks out for a long time; For 2, how to change the screen light?

谢谢!

推荐答案

- 你需要的是一个远程服务。这几乎是类似一个局部的服务(即用于在计步器例子),但即使没有活动势必它,在后台运行的服务。你可以关闭屏幕,甚至活动可能会崩溃(在不好的情况下)。),但该服务保持运行,如果你用startService(...)而不是bindService(...)开始了它

concerning 1 - what you need is a remote service. this is a service nearly similar to a 'local' service (that is used in the pedometer example) but can run even if no activity is bound to it, in the background. you can turn off the screen and even the activity can crash (in a bad case ;) ) but the service keeps running if you started it with startService(...) instead of bindService(...).

试图通过<一个获得href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/RemoteService.html"相对=nofollow>这个,看看有没有什么帮助。

try getting through this and see if that helps.

有关2 - 你应该使用(1);)

concerning 2 - you should really use (1) ;)

这篇关于在Android的后台传感器数据采集器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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