You have seen this thread has such a long history, 8yrs. Perhaps no one cares except we developers.
Be sure to close all sensors, set sessions and timers to Null on exiting.
Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:yourMethod)); //not in the api but good to do if using GPS…
noticed that I enable sensor and position events in some cases, but do not explicitly disable them on app exit. I've since updated my code to do disable them, but I'm still curious if this could be the…
Trying to reproduce sensor this issues, does anyone have some code that can trigger the battery drain?
F3b Software (Brian) do you still encounter the battery drain issue, if so, can you share some code to help us reproduce it?
Johnny.ConnectIQ Due to Garmin does not have a NDA and a PIIA with F3b, I cannot provide source code. I could try to create a generic build or a debug build.
It is likely best if you contact me via the Forum messages. Then we can start a phone call or teams meeting.
The bug can be in firmware...
I've noticed several cases with battery drain after finishing activity (f7 16.22). I can't reproduce every time but I think it' can be problem with GPS.
As I remember
- battery is low - about 10%
- choose activity with gps (my case was with walking) outside and wait for GPS
- start (I use only one, my, custom DF and read info.currentLocationAccuracy)
- after about 40 minutes (typical my activity) go inside the building - and wait for loosing GPS
- wait a few minutes and end activity (still without GPS)
probably from time to time system tries to fix gps
Do I need to call:
Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:yourMethod));
or
Position.enableLocationEvents(Position.LOCATION_DISABLE, null);
I've seen in multiple places that people are passing the method for the unregistering (I guess based on the RecordSample app from the SDK), but is that necessary, or better to call with null?
Found a bug that also might explain this battery drain: https://forums.garmin.com/developer/connect-iq/f/discussion/400587/watch-app-records-a-hike-session-and-my-hike-activity-s-unrelated-ciq-datafield-is-also-running
Looks like sometimes it's possible that the user does something (runs app A) and the system also runs app B, without the user knowing it. So it might look like app A is draining the battery, wile it can be caused by app B.
I'll add that in the above link I have an example where I noticed that this was happening because app B also recorded fit fields. But it is very much possible that app B doesn't write to the fit file, so the user will have no way of knowing about app B, and still in theory app B can run...