I´m recording an activity in my App. It seems to work on the Simulator and also on my vivoactive.
Start the App, push Rec (vibrates), record some Minutes (steps, time & heart rate), then push Rec again (vibrates), push back, App asks if I´d like to save => Yes. Application Close.
But there are several misbehaviour appearing randomly:
- After some time, the vivoactive freezes. When I restart it, there is an unreadable activity in the protocol
- Nothing happens and there is no activity in the protocol
- I start f.e. the running App. It shows a red border, which should indicate, that there is an open session. If I close the App, I can confirm canceling it. A progressbar appears and nothing happens until I reboot the device.
Whats going on there?
My code:
function initialize()
{
if(hasRecording == null)
{
hasRecording = Toybox has :ActivityRecording;
}
}
function ToggleRecording()
{
if(hasRecording)
{
if((session == null ) || (session.isRecording() == false))
{
session = Record.createSession({:name=>"Squash", :sport=>Record.SPORT_TENNIS});
session.start();
recorded = true;
Sys.println("Recording started");
}
else if((session != null) && session.isRecording())
{
session.stop();
}
}
}
function storeRecording(save)
{
if(hasRecording)
{
if(session != null)
{
if(session.isRecording())
{
session.stop();
}
if(save)
{
session.save();
}
else
{
session.discard();
}
}
}
Sys.println("Store Recording: " + save);
}
When the Application will be closed, I throw a confirmation dialog (Save/Discard). then I call storeRecording() with the result and afterwards, I return true to close the dialog.
The App in the simulator freezes (so I guess it closed properly) and on the device, I return to the Application overview.
It´s my last stage to release my App :(