How to start App Activity in Simulator?

Former Member
Former Member

Something missing here in my understanding, I have a simple App created in Eclipse, in the View class (extending WatchUi.View) I have an initialize() method that starts session recording. Currently my App displays Heart Rate, and I'm trying to add cadence. 

The recording works OK, when I sideload to my watch the FIT file is being created, and looks OK. Cadence is being recorded in the FIT file, but I am not able to show it in the UI because it's coming back as null from Activity.Info.currentCadence

Now I'm wondering whether my Activity has actually started, if I check the value of Activity.Info.startTime in the onUpdate() method it always returns null, even though session.isRecording() returns "true" .

So I guess I don't understand how an activity is started.

In the Simulator I can run Simulation / Fit Data / Simulate Data and Simulation / Fit Data / Playback File.... but always Activity.Info.startTime returns null.....I'm using Vivoactive 3 in the simulator (same as my actual watch) and have also tried clicking the button, to see if that might change the value of  Activity.Info.startTime, but to no effect.

Maybe I'm barking up the wrong tree, but why does  Activity.Info.startTime always return null?

Thanks

David

  • If there's a .fit generated, it's recording.  

    I've never used startTime.  Try displaying elapsedTime (it's the number of ms since recording started) or timerTime (ms that were actually recorded so doesn't include pauses)

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Activity.Info.elapsedTime also always returns null, even when session.isRecording() returns true,

    David

  • You create the session.  Do you start start it in your code?

    session.start();

    are you looking at Activity.Info on a timer (a new call to Activity.getActivityInfo() every timer tick)?

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    I do start the session with session.start() and session.isRecording() returns true. I am checking Activity.Info in the onUpdate(dc) method of my view. I don't have a timer.

    Thanks

    David

  • If this is a device app, how are you triggering onUpdate() to run?  It won't be called regularly without something that calls WatchUi.requestUpdate();  That most often is a timer.

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Yes, it's a device App. I did enable sensors for SENSOR_HEARTRATE and create an onSensor method that calls WatchUi.requestUpdate().

    I know the onUpdate() is being called because my debug statements are there, and printing OK. My debug statements, in onUpdate() report the following (when running in the Simulator)

    Activity.getActivityInfo() is NOT null

    session.isRecording() is true

    Activity.Info.timerTime is null

    Activity.Info.startTime is null

    Activity.Info.elapsedTime is null

    I have session.start() in my initialize() method, and this is running. Should this start the Activity?

    Thanks

    David

  • And you are doing a call to getActivityInfo() on each call to onUpdate?  It sure sounds like you aren't displaying the current info.

    session.start() starts/restarts the recording, and the fact that you're getting a valid fit file says that's happening

  • function onUpdate(dc) {
      var aInfo=Activity.getActivityInfo();
    
      System.println(""+aInfo.elapsedTime);
    ...
    
    }

  • Former Member
    Former Member over 5 years ago in reply to jim_m_58

    Ah....now the penny drops. I was just printing Activity.Info.elapsedTime without first having done a 

    var info = Activity.getActivityInfo();

    Now, I have added the getActivityInfo() method at the top of onUpdate my debug statements are showing me startTime, elapsed Time and timeTime.....

    Thank you for your patience!

    David

  • You can also get the HR there, and not need the sensor call back, but then you want to have a timer to do the requestUpdate()