![]() | MultipleSensors.pde run in background? |
|
05 Nov 2012, 11:40
Olaf Heddergott (11 posts) |
I have compiled and installed MultipleSensors.pde on my samsung galaxy SIII. If I run the app once and leave it with the back button, it is permanently showing in the power overview. It looks like the app is continuously using the cpu. why? |
|
08 Nov 2012, 17:36
Daniel Sauter (38 posts) |
Hi Olaf, you need to call the KetaiSensor stop() method to pause the sensors. This gives you the control to start and stop capturing sensor data when your app requires it, and not via the Android life cycle onPause(). Some applications require to keep capturing sensor data in the background, so it’s important to allow for it. Best, |
|
13 Nov 2012, 08:36
Olaf Heddergott (11 posts) |
I extended the source code with the exit function like shown below. With ketai v7 and v8 and MultipleSensors.pde (with exit function) I call stop with no luck. I start the MultipleSensors on phone, close it and load the mobile to 100%. then disconnect the power supply and looking in the accu usage and see MultipleSensors is running without end. the only way to stop is deinstallation. I write a little sample for the light sensor (at this time I only need this sensor) and test it with ketai v8. this is not running in background. here my sample: import ketai.sensors.*; KetaiSensor sensor; void setup() void draw() void onLightEvent(float v) void exit() can the problem be in usage other sensors as the light sensor? I test the sensor.stop in many ways but the result is the same. Must I stop the accelerometer and the other sensors separately? |
|
17 Dec 2012, 07:53
Daniel Sauter (38 posts) |
Dear Olaf, the KetaiSensor stop() method works as exhibited in the MultipleSensors Example of Chapter 3.6 “Kill” an activity is handled by the Android system, and apps that try to kill themselves (onPause() or exit() or finish()) will be restarted and paused back of the application stack. calling sensor.start() in setup() will also re-activate your sensors. Best, |
| You must be logged in to comment |

