Problems with porting an app to Forerunner 235

Former Member
Former Member
Hi

I wrote an app that works on my Fenix 5X. I was asket to compile it for the Forerunner 235, what I dit but I encounter 2 issues :

- on the simulator, calling System.exit() raises an IQ error ???
- on the real watch I was told that Up, Down and Return keys don't work. Everything is OK with the simulator...

Any hints ?

Thx
  • In your delegate, make sure that you are doing a proper return, which in most cases will be "return true". What version of the SDK are you using? For the Sys.exit(), that could be involves. Also, have to tried returning false in onBack() to exit?

    Maybe post the code for your delegate if you still have problems.
  • Former Member
    Former Member
    Here are my delegates :

    // Handle menu button press
    function onMenu()
    {
    // System.println( "In onMenu");
    //makeRequest();
    // System.println( "Leaving onMenu");
    return true;
    }

    function onSelect()
    {
    // System.println( "In onSelect");
    viewControler.stopTimer();
    // System.println( "Timer stopped" );
    viewControler.startUpdateProcess();
    // System.println( "Leaving onSelect");
    return true;
    }

    function onKey( evt )
    {
    var key = evt.getKey();
    var key_name = key.toString() + " Key";
    // System.println( "In onKey - " + key_name );
    return true;
    }

    function onKeyPressed( evt )
    {
    var key = evt.getKey();
    var key_name = key.toString() + " Key";
    // System.println( "In onKeyPressed - " + key_name );
    return true;
    }

    function onKeyReleased( evt )
    {
    var key = evt.getKey();
    var key_name = key.toString() + " Key";
    System.println( "In onKeyReleased - " + key_name );

    if( key == KEY_UP )
    {
    viewControler.viewUp();
    return true;
    }

    if ( key == KEY_DOWN )
    {
    viewControler.viewDown();
    return true;
    }

    if ( key == KEY_ESC )
    {
    if( viewControler.getScreen() == 1 )
    {
    System.println( "Just before System.exit();" );
    System.exit();
    System.println( "Just after System.exit();" );
    }

    if( viewControler.getScreen() == 2 )
    {
    viewControler.setScreen(1);
    }

    return true;
    }

    return false;
    }

    Of course the code after "System.exit()" is not executed.... I put it to make sure where the IQ error was occurring. Looks like the exit itself is the origin...
  • I'd do away with the keyPressed/keyReleased code, as that's not needed and if I recall, doesn't work that well on devices. Things like KEY_UP and KEY_DOWN should be part of onKey() and not attached to pressed and release.

    For me, I'd do away with how you do KEY_ESC, and move that into onBack() and return false when you want to exit.

    With returning true in onKey() all the time, the onKeyPressed and onKeyRelease likely aren't being called on the 23x this way.
  • Former Member
    Former Member
    Thx. It solved the issue !