Ticket Created
over 3 years ago

CIQQA-709

unable to read details of activity just completed in onActivityCompleted() handler

I'm trying to read the read details of activity just completed in onActivityCompleted() handler in a widget like this:

function onActivityCompleted(activity) {
   var actInfo=Activity.getActivityInfo();
   if (actInfo!=null) {
    var activityCal=actInfo.calories; // returns Number (int)
    var durationInMs=actInfo.elapsedTime;
    var maxHR=actInfo.maxHeartRate;

.....

The maxHR and calories are always null and the duration is always 0.  

It may be coincidental but I was using just the maxHR and it was working (although on a datafield), before the update to SW version 6.4 on the VA4S last week.

It may be however that it was not working even before last week's watch SW update to version 6.4 on the VA4S, since I have not checked in a few weeks and I have not gone back to check the datafield.  It may or may not be working.

I cannot comment on the calories and duration values because I had not previously read them before.

Parents
  • This is working as intended.

    When the activity ends, the .fit file is saved, the session is closed, and a notification is sent to the system to tell it to invoke onActivityCompleted in the background for any app that is registered for that callback. By the time that the callback is invoked, the activity may have been inactive for some time. I believe it is even possible that a new activity could have  been started; which means you'd get data for the wrong session with the code you've posted above.

     

Comment
  • This is working as intended.

    When the activity ends, the .fit file is saved, the session is closed, and a notification is sent to the system to tell it to invoke onActivityCompleted in the background for any app that is registered for that callback. By the time that the callback is invoked, the activity may have been inactive for some time. I believe it is even possible that a new activity could have  been started; which means you'd get data for the wrong session with the code you've posted above.

     

Children
No Data