Buttons work in simulator, not on device

Former Member
Former Member

I have an app in BETA mode on the ConnectIQ Store. I updated the latest update and I know it worked because I changed a default property, which updated as expected. I try to press the MENU button the the Forerunner 235 and I expect it to go into the options menu. But it doesn't. Hitting ENTER does not start the watch's functionality (a multi-function clock). However, hitting the LAP/ESCAPE key exits the app, after a several second delay, not expected. 

Running the simulator works 100% fine. No delays, runs smooth and great. However, I do receive a memory/circular references warning. "A snapshot of active memory just before App shutdown is currently shown. These leaks... may reduce the memory available while the app is running." The following is the statistics on memory...

Memory Usage: 31.5/64.0 kB

Peak Memory: 32.5 kB

Object Usage 122/512

Peak Objects: 133

The item listed with Circular Reference! in its note has the following information: 

  • <Entry Point> (type) object     (Created at) native function
    • appView
      •        - app      (type) object     Circular Reference!
      •        - remind      (type) boolean     (value) false  
      • mProperties      (type) null      (value) null
      • mPropertiesChanged      (type) boolean      (value) false    

Any help? I'm not sure the memory is related, but thought it could help. Fixed the memory issue.

  • Something odd with your input delegate is my guess,,  Something with the onXXXX() functions - make sure they always return a true/false value.

    With a sideload, include some Sys.println() calls in the delegate to make sure things are called.Create a <yourapp>.txt file in the garmin\apps\logs folder on the watch to catch the output

  • Former Member
    Former Member in reply to jim_m_58

    So I managed to find and remove the Circular Reference/Dependency, but did not fix the input issue. I have returns on all the input functions and I have log calls. The only thing that doesn't run is the onXXXXX() input functions.

  • Maybe post the code for your delegate (use insert>Code so it doesn't lose formatting).

    Are you going by onKeyPressed() and onKeyReleased() by any chance?  Try just using onKey()

  • Former Member
    Former Member in reply to jim_m_58

    I am using both onKeyPressed and onKeyReleased to determine how long a button has been held... I couldn't find any other way to do it. I'll post my code in a bit, I want to clean it up before I post it public :P

  •  Unfortunately, on 235 (and similar devices from the same generation), you just cannot detect a long press. Furthermore, there are so many long press events for various devices (either system-level/non-overrideable or optional hot keys), that even if you could determine how long a button was pressed some of the time, it's just not worth it.

    Trust me, I learned this the hard way. I made an app that had long press functionality for every device, then I found:

    - Half the devices couldn't detect it no matter what (e.g. 230, 235, 630, 920XT, etc.)

    - Some devices had system-level long presses that couldn't be overrideable, that I wasn't expecting (e.g. long press of button on VA3, long press of Start on VAHR)

    - Some devices have long press hotkeys that are enabled by default (like holding Down to go back to the clock on the some devices)

    - Some devices have user-defined hotkeys, where they can assign functions to a long-press of any button that the system doesn't use. So even if you can detect long press, your users may have a setting that interferes with your functionality

    I ended up making the long-press functionality completely optional, and disabled by default.

    If you really want to do this in a way that sorta works on all devices, you need to fall back to onKey if onKeyPressed isn't triggered. You can do this by setting a flag when onKeyPressed is triggered, and ignoring the subsequent onKey if that flag is set. But I don't think it's worth it, because of all the issues above.

    Further reading:

    https://forums.garmin.com/developer/connect-iq/f/discussion/4562/onkeypressed-and-onkeyreleased-on-fr230-235-735

    The bottom line is that the onKeyPressed() and onKeyReleased() functionality doesn't work, or at least doesn't work with many devices, at this point in time. 

  • Thanks for your post - I was about to try some long key press tests, but you have saved me a lot of time Slight smile

  • Trying to do long press detection is hard.  It's not consistent between devices, touch vs non-touch, devices with hot keys, devices with music, etc.  Stick with things in the UX guide.

  • Yep I'll just stick to onNextPage(), onPreviousPage(), onSelect() and onBack() and keep things simple Slight smile

    Although onMenu() is seeming to work as well, which is useful (and that's a long press, but handled automatically).

  • With onKey() you might find some things useful there to.  Like KEY_LAP on edge devices where there's a seperate lap key