Hello,
I develop a watch face and I use in watch setting menu, with function getSettingsView().
I want to save the settings into the application storage, which works fine in the simulator, but fails on the device.
Is there a special trick to apply?
Sample code which fails, if comment the Application.Storage.setValue command then all works fine on the watch :
import Toybox.Application;
import Toybox.Lang;
import Toybox.WatchUi;
class sampleWatchFace extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state as Dictionary?) as Void {
}
// onStop() is called when your application is exiting
function onStop(state as Dictionary?) as Void {
}
function getInitialView() as Array<Views or InputDelegates>? {
// Fails on the device with a black screen with the Connect IQ icon:
Application.Storage.setValue("testKey","testValue");
return [ new watchFaceView() ] as Array<Views or InputDelegates>;
}
function onSettingsChanged() as Void {
WatchUi.requestUpdate();
}
function getSettingsView() as Array<Views or InputDelegates>? {
var delegate = new MyMenuDelegate();
var menu = new WatchUi.Menu2({:title=>"Options"});
menu.addItem( new MenuItem( "Opt1", null, "opt1", {} ) );
menu.addItem( new MenuItem( "Opt2", null, "opt2", {} ) );
menu.addItem( new MenuItem( "Opt3", null, "opt3", {} ) );
return [ menu, delegate ] as Array<Views or InputDelegates>;
}
}