What is the appropriate implementation for app developers to ensure proper exiting/backing out of a watch app? Currently, when I load my app onto my Fenix 3 it works well but when I press the "Back" button to exit, it crashes. The code for my main BehaviorDelegate is below.
Also - a previous version of this code was not implementing onBack, and still crashed. Any help is appreciated - thanks.
(On a related note - what is the appropriate handling for the Up/Down keys in a widget to ensure that one can cycle to the adjacent widgets? Or should they be left un-handled?)
class LoopTimerDelegate extends Ui.BehaviorDelegate
{
hidden var app;
function initialize()
{
app = App.getApp();
}
function onMenu()
{
Ui.pushView(app.getNewSettingsMenu(), new LoopTimerMenuDelegate(), Ui.SLIDE_UP);
return true;
}
function onBack()
{
// Handle exiting
Ui.popView(Ui.SLIDE_RIGHT);
return true;
}
function onKey(evt)
{
var key = evt.getKey();
var handled = false;
if (WatchUi.KEY_ENTER == key)
{
app.toggleTimer();
handled = true;
}
else if (WatchUi.KEY_DOWN == key)
{
// Reset the timer
app.resetCurrentIteration();
handled = true;
}
if (handled)
{
Ui.requestUpdate();
}
return handled;
}
}