Show DataField value when save activity

Hi,

I dont find that function to be used to force the display of a datafiled in "onStop()". I want something like "recovery time" screen when save an activity.

Does anyone know how to do it?

Thanks
  • I do not believe that a data field can push a new view, so you most likely won't be able to do what you're planning. Additionally, at least on some devices, data fields aren't unloaded after saving/discarding an activity. They are only unloaded when switching activity profiles or exiting back to the watch face. There was a bit of functionality to display a message banner in an earlier release, but it was removed as it was not complete at the time. That feature may make a comeback.

    There have been requests to add callbacks to make it easy for developers to know when an activity is started, stopped, paused, and resumed, but I haven't seen anything to indicate the functionality is available. Until that feature is implemented, you can use the startTime value of the Activity.Info that is passed to your data field to determine when a session is started. If you cache the previous value of startTime, you can compare the current and previous start times, and if they are different you know that a new activity recording session has been started.

    With this information, you should be able to display the data field data after the recording has completed and been saved.

    Travis
  • you can use the startTime value of the Activity.Info that is passed to your data field to determine when a session is started.

    You can use info.elapsedDistance and a cached copy of the last value to tell if the activity session has stopped, and you can use info.timerTime and a cached copy to handle pausing. I _believe_ that the following should work.

    //! called when recording is stopped
    function onTimerStop() {

    }

    //! called when recording is started
    function onTimerStart() {

    }

    //! called when recording is paused
    function onTimerPause() {

    }

    //! called when recording is resumed
    function onTimerResume() {

    }

    hidden var elapsedDistance;
    hidden var timerTime;
    hidden var timerPaused;

    function compute(info) {

    //
    // handle stop/start of the activity recording session
    //

    if (elapsedDistance == null && info.elapsedDistance != null) {
    onTimerStart();
    }
    else if (elapsedDistance != null && info.elapsedDistance == null) {
    onTimerStop();
    }

    elapsedDistance = info.elapsedDistance;

    //
    // handle pause/resume due to auto-pause or button press
    //

    if (timerTime == null) {
    timerPaused = false;
    }
    else if (timerTime == info.timerTime) {

    if (!timerPaused) {
    onTimerPause();
    }

    timerPaused = true;
    }
    else if (timerTime != info.timerTime) {

    if (timerPaused) {
    onTimerResume();
    }

    timerPaused = false;
    }

    timerTime = info.timerTime;

    // your other code
    }


    Travis