ActivityRecording Module

Former Member
Former Member
I am currently experimenting with the recording module with the vivoactive, it seems to be working ok which is great :)

I notice when I am using the garmin supplied apps, when you save an activity, it displays a progress bar which moves along as the file is saved.

Is this at all possible with the Connect IQ SDK ? There just seems to be a save() function that returns true/false. Does not seem to be anyway of determining how long it might take so not sure how I can display a progress. I just want to make my apps behave as similar as I can to the default apps.

Also, can I get some confirmation from garmin, when I start / stop a session, the vivoactive will vibrate automatically. I noticed someone posted code yesterday where they are manually calling the Att.vibrate function. Do we have a list as to which devices will automatically vibrate and which ones don't? I assume the code I was shown yesterday will vibrate twice on my watch.

One more thing, what happens to a recording session if you don't save or discard it? When you click back out of the App does it automatically discard it?
  • Former Member
    Former Member over 10 years ago
    and yet one more thing, the user guide says that the back/escape button should be disabled when there is an activity being recorded. I have tried many things, but I cannot work out how to disable the back button. I have tried returning false in onBack() function, but it still exists.

    in my App code which I copied from the samples, it calls stopRecording from my main view, but it does not actually disable the button. I would prefer not to allow it to stop at all if there is a recording going on. I would prefer user to have to hit the ENTER key to stop the recording first.

    function onStop() {
    c25KView.stopRecording();
    }


    any ideas?
  • Returning false from the handler indicates you didn't do anything in response to the event. If you want to avoid the system behavior, you should return true.
  • Former Member
    Former Member over 10 years ago
    Thanks TRAVIS.VITEK :) It now works as i want it to..

    With regards to the progress bar, I have just set a timer that updates once per second that starts before the save, it shows "busy" until the operation has been completed, then displays the progress bar for a further 3 seconds with the "Complete" message. I think this is what the standard one must do also.

    The only thing I would like to know now, is if its possible to change the color of the progress bar. The garmin one is blue i think, the one I get is not the same.
  • it shows "busy" until the operation has been completed

    How do you know that saving the file is complete? I don't see any callback or anything that would tell you that.

    is if its possible to change the color of the progress bar

    No, I see no way to specify the color of the progress bar. I suppose that you could request a ProgressBar.setColor() method be added or that the built-in progress bar be consistent with whatever the system progress bar would be (which depends on some user settings).

    Travis
  • You must be polling the result of Activity.save() to see when the save completes. I hadn't thought that this would be necessary, but if it is I guess I'll handle it.

    Thanks!

    Travis
  • Former Member
    Former Member over 10 years ago
    How do you know that saving the file is complete? I don't see any callback or anything that would tell you that.


    It either returns true or false when its finished, not that I have done anything with that, but I am assuming that it waits to return before continuing with the next instruction, so I just do this

    ... inside an onKey event.....

    if( ( session != null ) && session.isRecording() ) {
    if ( progressTimer == null ) {
    progressTimer = new Timer.Timer();
    }

    Ui.pushView( progressBar, null, Ui.SLIDE_DOWN );
    progressTimer.start( method(:timerCallback), 1000, true );
    operationComplete = false;
    session.stop();
    session.save();
    operationComplete = true;

    .......

    function timerCallback()
    {
    if ( operationComplete == false ) {
    Sys.println("Operation Not Complete");
    progressBar.setProgress(null);
    }
    else {
    if ( progressCloseDelayCount == 3 ) {
    Sys.println("Starting counter to show for 3 seconds");
    progressBar.setDisplayString( "Complete" );
    progressBar.setProgress(100);
    }


    if ( progressCloseDelayCount == 0 ) {
    Sys.println("Finished, stop timers and pop view");
    progressTimer.stop();
    Ui.popView( Ui.SLIDE_UP );
    }

    progressCloseDelayCount--;
    }
    }


    I have just pulled some code to give an idea of what I am doing. I think its probably the right way to go.. hopefully.. :)
  • Former Member
    Former Member over 10 years ago
    Question with regards to the ActivityRecording module and applications that use it...

    When you start an app, what actually triggers the app to go looking for GPS signal, is it this function below?

    enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));


    If so, when you use LOCATION_DISABLE, this would turn off the GPS position and possibly lose GPS communications correct?

    I am basically trying to implement a pause routine in activity recording, but, I don't want to lose the GPS location while I am paused. If I just call session.stop() when user has paused, am I able to call session.start() again and it will continue recording to the same FIT file?

    Also, if I hit a menu item and the menu stays on screen, I don't want to lose the GPS location, so does the enableLocationEvents function still work in the background view?
  • When you start an app, what actually triggers the app to go looking for GPS signal, is it this function below?

    Yes, that is the function that enables/disables GPS for your app.

    If so, when you use LOCATION_DISABLE, this would turn off the GPS position and possibly lose GPS communications correct?

    Yes.

    I am basically trying to implement a pause routine in activity recording, but, I don't want to lose the GPS location while I am paused.

    Data recording is completely separate from GPS. Turning one off does not affect the other.

    If I just call session.stop() when user has paused, am I able to call session.start() again and it will continue recording to the same FIT file?

    Yes. If you don't want to lose GPS, then don't turn the GPS off. Starting and stopping the activity doesn't turn GPS on or off, it just starts and stops the recording of data to the fit file.

    Also, if I hit a menu item and the menu stays on screen, I don't want to lose the GPS location, so does the enableLocationEvents function still work in the background view?

    I'm not certain. You can write test code to see for yourself.
  • Thanks TRAVIS.VITEK :) It now works as i want it to..
    The only thing I would like to know now, is if its possible to change the color of the progress bar. The garmin one is blue i think, the one I get is not the same.


    If you call dc.setColor just before initializing the ProgressBar, it'll change it's fill color to whatever you've specified as foreground color.
    dc.setColor(Gfx.COLOR_DK_RED, Gfx.COLOR_DK_GRAY);
    progressBar = new Ui.ProgressBar(tMessage, null);
    Ui.pushView( progressBar, null, Ui.SLIDE_DOWN );
    // a red progress bar


    This might not be intended behavior though...
  • Former Member
    Former Member over 10 years ago
    If you call dc.setColor just before initializing the ProgressBar, it'll change it's fill color to whatever you've specified as foreground color.


    This might not be intended behavior though...



    Thanks for that, I did notice that in the simulator, but didn't really try in on the watch. I will try it when I have the code done for that part.