Pause an ActivityRecording

Former Member
Former Member
Hey!
Is there a way to pause a session? if there isn't,then what is the best way to make it act like it's pausing?
And can anyone point me to an example code or describe me how to record a map?

Thank you!:)
  • There a number of things going on here, but not sure what with no code to look at. Have you considered just letting the recording continue but turning off GPS when you don't need the data? (I'd not do this BTW, for a number of reasons)

    Maybe just let the recording go on, and when you get to a POI, have the app do a markLap to save the "point"?

    I use start and stop to handle manual pauses in my app, and without seeing your code, not sure why it's not working for you
  • Former Member
    Former Member over 8 years ago
    Hi Jim. Thanks for that. My code is a bit spaghetti at the moment, LOL. If I were to leave it running and turn the GPS on and off, is it possible to disable other sensors to save battery? When I turn the GPS on, will it put only new data in the FIT file? I see "last known position" for a few seconds after turning it on, before it gets a good signal. I guess that's why I don't want to try a ONE_SHOT location request.
  • hi friends,

    when i have pause (speed =0) i put session.stop in this way.

    function update(dc) {

        if( ( session != null ) && session.isRecording() && (activityInfoX.currentSpeed == 0) ) {
              session.stop();
        }
       else {
           session.start();

       }

    }

    but i receive error message that session.start() not works on update(dc) function.

    how i can do ?

    thanks

  • What's the error message say?

    But, I also wouldn't do this in onUpdate().  Consider the following.

    User is running your app and gets a notification, stops to look at it/deal with it.  During that time, your onUpdate() doesn't run.  Same if the user opens the music player, stops to pick a playlist.  Same thing.  You're onUpdate() doesn't run.  It would be best to do this in a timer.

    Also, speed=0 isn't a sure thing, as with GPS, there's a bit of a "wobble" where that may indicate you're moving a bit when you're standing still.  Try starting a GPS activity and just put the watch on a table, and you'll see things like distance climbing.

  • Error: Unexpected Type Error
    Details: Failed invoking <symbol>
    Stack:
    - onUpdate() at C:\Users\scdstf\eclipse-workspace4\GpsBike51_autostop2\source\InputView.mc:290 0x10001904 Unexpected Type Error
    in onUpdate (C:\Users\scdstf\eclipse-workspace4\GpsBike51_autostop2\source\InputView.mc:290)

  • In your code you will repeated call start() each time onUpdate() is called unless the speed is 0.  It could just be things go haywire when that many starts are called when the session is already started.

  • You probably don't want to mess with turning sensors or GPS on/off.  Consider GPS, when you turn it back on, it could take a bit of time before it gets a new fix.  And the Tempe can take about a minute to reconnect.

    ONE_SHOT really isn't an option.  What can happen is you can get a "Last_known" location accuracy, when you really want GPS fired up.

  • In your code you will repeated call start() each time onUpdate() is called unless the speed is 0.  It could just be things go haywire when that many starts are called when the session is already started.

    Yes Jim. My code not works now.

    I must evaluate fine where i can put re-start session.

    thanks

  • if you want to avoid repeatedly calling start() or stop when you don't need to, you could just use a boolean

    var pause=false;

    ...

    if(.. && !paused) {

      paused=true;

      //do stop()

    } else if(.. && paused) {

      pause=false;

      //do start();

    }

  • function update(dc) {

        if( ( session != null ) && session.isRecording() && (activityInfoX.currentSpeed == 0) ) {
              session.stop();
        }
       else {
           session.start();

       }

    }

    If session == null, you call session.start(), which results in an unexpected type error (the null object has no methods).

    That said, I'm with @jim_m_58. You should consider doing this outside of your draw code. You should use a timer or the sensor callback for stuff like this.