Complex Datafield Integration within a custom App

Goodmorning, 

I'm at the stage where I have a complex datafield that is working when I add it to a Garmin activity.

I've also started creating an app, that I want to display that datafield.

I thought it would be a simple case of pushing the view from my first screen and delegate, to the datafield view, and I added a data field view delegate. to initiate some things.

In the eclipse editor watch simulator, it works.

On the actual watch it crashes when the datascreen is pushed, causing the watch to reset.

Is there something more I have to do, than just try and bring up my datafield view? do I need the watch to have commenced activity recording prior or something?

Or initiated a session?

confused !@

  • You can't use a custom or natrive Data field in a CIQ device app.  The code involved must be in the device app itself.

    If you have the code in your device app, you likely  need to have the view extend Ui.View and not Ui.Datafield

    Also, in a device app, compute() etc isn't call, so it's not something that's simple to do.

  • Thanks again, 

    So the solution would be change the view to Ui.View.

    Move the entire contents of compute() under onupdate(dc)

    All of my calls were using Info. calls within compute(info) so I need to change all of them to a different source..

    I tried to replace those calls with getActivityInfo(), and they are all returning null......

    Does this mean Activity Info object does not work in custum CIQ apps? 

    also I added a line in the APP.mc to try and get it to work, , but I get an error on that line now.

    using Toybox.Application;
    using Toybox.WatchUi;
    using Toybox.System;
    using Toybox.Position;
    
    
    
    class SailRacerApp extends Application.AppBase {
    
    
    
    function initialize() {
    AppBase.initialize();
    }
    
    // onStart() is called on application start up
    function onStart(state) {
    Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
    }
    /// enable the GPS to update once a second, read with Info.position
    // onStop() is called when your application is exiting, to save dataa to the object store
    function onStop(state) {
    
    // DataFieldView.stopRecording();
    // Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
    
    }
    
    // function onPosition(info) {
    // }
    
    
    // Return the initial view of your application here
    function getInitialView() {
    return [ new WindView(), new WindDelegate() ];
    }
    
    }
    
    

  • if you want to try an make use of compute() in a device app, what you could do is create a timer that fires every second and in it, call compute(Activity.getActivityInfo())

    The whole management of the recording is different in a device app than a DF, as in a DF, that his all handled outside of the DF.

  • Thanks Jim, now working

    When I implemented it I had to use function compute(info).... Why did I have to put info in there?

    On the recording part, are you hinting that if I wish to record any of the values I'm now displaying, that will all need to be coded within my app.... none of the Activity info stuff is recorded? or if I start a recording session is the app.... will it  default to the activity info info ?

    I see there are examples, but these are all about recording Activitymonitor datatypes