Question Regarding Activity Metrics in MonkeyC Application

Hi

I am currently developing an application using MonkeyC, where I utilize Activity.getActivityInfo() and ActivityMonitor.getInfo() to retrieve activity metrics from the device. In the simulator, everything works as expected; however, when I deploy the application to an actual device, it crashes.

After testing and analyzing the issue, I have determined that the primary cause seems to be the retrieval of the aforementioned metrics. The only way I have been able to prevent the application from crashing is by delaying the retrieval of these metrics.

Additionally, I would like to know if there is any form of garbage collection available or recommended techniques to avoid this problem?

Any guidance or suggestions you could provide would be greatly appreciated.s

  • Not sure how garbage collection would help.

    You could've looked at the crash report (easiest in ERA Viewer if it's an app from the store, i.e a béta app) or in the apps/logs folder on the device, which needs some dec2hex conversion (the only reason for this I can imagine is that Garmin intentionally wants to make debugging harder...) and some guess work to find the line number.

    After you found the lines where the error happens, you probably will understand alone what is the reason, Look for possible nulls! 

    If you still couldn't find it and you read the documentation of the functions you use and checked for possible wrong assumptions (i.e other possible return type or Null :) then post your relevant code with the error.

    Alternatively you can also send me a machine to help me read your mind ;)

    Honestly I don't know why we don't have a thread with a FAQ that tells new users how to post a question.Maybe I should start one...

  • Thank you for your willingness, I have already solved the error. The problem was that when the sensor did not record a value, it returned null and that threw an error in the calculations. In the simulation "the sensor is still running" that's why it just didn't work on the watch. I have already ensured that and everything works.

  • That's why in the documentation it says:

    getActivityInfo() as Activity.Info or Null
    Get the current Activity Info.

    It's important to realize that differente value types can be returned. Always work with the api documentation close to you.

    developer.garmin.com/.../Activity.html