views:

26

answers:

1

I'm creating a datalogger which logs the gps data and the sensor data of the phone. I've just a strange problem. If the phone is not touched for few minutes it goes into standby mode (screen goes black), and that causes the logger to stop working. Actually the firewriting in the logger stops working. The GPS resumes fine after coming out of blackscreen, but when I check the log I created it only shows saved points for few minutes.

Does anyone have idea what is causing this?

+1  A: 

This is normal behaviour to save battery. Unless the phone is explicitly told to 'wake up' by your program, everything is stopped while in standby mode. I haven't experimented with this before so can't give any code, but I suggest you look at the Alarm Manager. However, there are two things to note: First off, this will kill the battery in no time if you have it log too often. You must be very careful implementing this alarm and if necessary the associated WakeLock. Secondly, you must make the user aware that it will continue logging even during standby, so that they aren't surprised when the battery is much lower than when they left it.

Steve H