Hi! I'm trying to access sensor data in a widget by using a background service, but it seems I'm missing something. Maybe someone can put me on the right track?
I want to create a widget that accesses sensor data in a background process. Background processes can be executed every 5 minutes for around 30 seconds, so I am creating a temporal event for that time frame. When my temporal event is fired after 5 minutes, my callback is called. Now i am creating a sensor event where i want to listen to, for example, accelerator events:
function myBackgroundCallback() {
var options = {
:period=>1, // 1 second sample time
:accelerometer=>{
:enabled=>true, // Enable the accelerometer
:sampleRate=>10
}
};
Sensor.registerSensorDataListener(method(:sensor_callback), options);
//...
The problem is: my sensor callback sensor_callback will never be called because when i leave my myBackgroundCallback function, it seems my background time gets ended.
Probably I am doing a stupid mistake here. Can somebody point me into the right direction?