See also
ActivityRecording::Session - rapid short recordings corrupt files, crash app
and
Second consecutive Session fails to start
I have the problem slightly different as in above posts.
I'm making a multisport app and wanted to create consecutive sessions. Have not tried it yet on a real device, only talking about the Simulator.
Anyway, with 5 session e.g. the 1st, the 3rd and the 5th work
(with "work" I mean it records Activity.getActivityInfo().elapsedTime)
In the 2nd and 4th session though Activity.getActivityInfo().elapsedTime returns 0.
Mind: this happens in the Simulator!
At the beginning of every session I do
- arjSession = ActivityRecording.createSession and
- arjSession.start()
At the end of every session I do
- arjSession.stop() and
- arjSession.save()
as we're supposed to do it. arjSession.save() always returns true.
After reading above posts, I programmed a pause of some seconds between the end of one session and the beginning of the following one.
And see: now it functions and all 5 sessions are stored.
Problematic anyway: first of all I do not know how long the pause has to be. Secondly, the recording becomes unprecise: every session misses some seconds so the sum of the sessions is less than the total elapsed time really is.
Now I am hesitating what to do: I could also record everything as one big session and work with laps (as in the triathlon app of hMSport in Connect IQ) but that is not what I wanted.
In the first post I referenced above, a pause of 500 ms was used, is there a guarantee that this is sufficient?
Another reason of going to the lap-solution would be that with the session-solution I do not record one multisport-activity but I have several loose sessions stored. Especially the total time is missing. Of course I can display the total time when the app is running, but I do not know how to store that. Create a field "totalTime" ? That would be incomprehensible to read afterwards probably in "Garmin Connect" or "History".
Thoughts?