電話のGPSデータとセンサーデータをログに記録するデータロガーを作成しています。私は奇妙な問題を抱えています。電話に数分間触れないと、スタンバイモードになり(画面が真っ暗になり)、ロガーが機能しなくなります。実際、ロガーのファイアライティングは機能しなくなります。GPSはブラックスクリーンから出た後は正常に再開しますが、作成したログを確認すると、保存されたポイントが数分間しか表示されません。
誰かがこれを引き起こしているものを知っていますか?
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.