timerState not available getActivityInfo

Hello,

I have a FR630, running eclipse with SDK 2.2.4 on windows. My manifest file has minSdkVersion="1.3.0".

My datafield uses settings, pushes some memory limits, and overall should be pretty cool, however I'm coming across an error in my onUpdate field which prevents it from showing anything on the display. After placing some system.println's I have determined that the code below is causing the watch to "ERROR: Symbol Not Found Error"... So I tested a few cases, and discovered the following:

In my onUpdate function I run the following code in the simulator, and everything works fine:
Sys.println("1");
var t = Act.getActivityInfo();
Sys.println("2");

if (t has :timerState) {
Sys.println( "t has :timerState");
} else {
Sys.println( "t does not have :timerState");
}

if (!t.timerState.equals(Activity.TIMER_STATE_ON)) {
Sys.println("3");
dc.setColor( Gfx.COLOR_YELLOW , Gfx.COLOR_YELLOW );
}
Sys.println("4");


The output (when run in the simulator) is:
1
2
t has :timerState
3
4


However when upload this code to the appstore (because my datafield uses settings), and sync the app to my watch, the watch displays the exclamation point error, outputs "ERROR: Symbol Not Found Error" to the CIQ_LOG and the program output text is:
1
2
t does not have :timerState


Please help!!! Any ideas?? I'm not sure it would help any, but is there a way to get more debug information outputted to the text files, in particular the CIQ_LOG.txt?

The purpose of my code is to change the background of the datafield depending upon the state of the activity, off (yellow), on (either white or green depending upon another variable). any alternative coding methods that would work?
  • if (t has :timerState) {
    Sys.println( "t has :timerState");
    } else {
    Sys.println( "t does not have :timerState");
    }

    if (!t.timerState.equals(Activity.TIMER_STATE_ON)) {


    I'll hazard a guess that the issue arises because you're asking to evaluating [FONT=Courier New]t.timerState[/FONT] even if [FONT=Courier New](t has :timerState)[/FONT] is false. You should move the second [FONT=Courier New]if[/FONT] statement into the first clause of the first [FONT=Courier New]if[/FONT] statement.
  • I'll hazard a guess that the issue arises because you're evaluating t.timerState even if [FONT=Courier New](t has :timerState)[/FONT] is false.


    Thanks for the reply. Actually, this code below was purely for debug purposes, to highlight how it DOES work in the simulator but NOT on the watch...
    if (t has :timerState) {
    Sys.println( "t has :timerState");
    } else {
    Sys.println( "t does not have :timerState");
    }


    In my datafield I NEED to evaluate timerState in the onUpdate function, so that I can color the background properly. Is there any other way to evaluate timerState in the onUpdate function? If so I'd really like to know it!

    So, okay I see what you are saying... that perhaps I need to wait until, or operate under the assumption that t (getActivityInfo) goes not have timerState. I looked up timerState in the API docs, and it says it existed since SDK "2.1.0" Does that mean that it is unavailable to my FR630 watch?

    I could use a separate variable which is updated in another function, however in the interests of saving memory I was hoping to use the getActivityInfo function, and not have to create another variable.
  • In my datafield I NEED to evaluate timerState in the onUpdate function,
    ">we know there are some things we do not know.”">“Reports that say that something hasn't happened are always interesting to me, because as we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know.”—Donald‑Rumsfeld

    You NEED to change the logic if what you WANT to know cannot be known (due to limitations in the SDK or otherwise). Insisting on proceeding regardless is folly.

    Does that mean that it is unavailable to my FR630 watch?
    I guess so.

    I could use a separate variable which is updated in another function, however in the interests of saving memory I was hoping to use the getActivityInfo function, and not have to create another variable.
    I'm not sure what you mean by that. You want to switch colours on the basis of the state of the activity, so the fundamental question is whether you can know the state at any given time (that the code fragment may be executed). I don't know the answer to that, since I'm not familiar enough with the SDK, let alone what's in 1.3.0 and what came later.

    <EDIT>
    I suppose you can use the [FONT=Courier New]onTimerStart[/FONT], [FONT=Courier New]onTimerStop[/FONT], [FONT=Courier New]onTimerPause[/FONT] and [FONT=Courier New]onTimerResume[/FONT] methods in SDK 1.3.0 to update a state variable that you maintain separately.
  • heh heh... okay, I see now. Yes since that timerState is only avail since 2.x it would be unavail to my FR630, which operates on 1.3.x. Alright. Thanks
  • I filed a bug report on this earlier in the week. The simulator is supposed behave like the device (the has check should fail since the feature is only available to devices with support for ConnectIQ 2.1.0 and later).

    Travis
  • I encountered exactly the same while trying to develop something for a Vivoactive. My fault for not reading the API documentation properly but worked fine on the simulator yet failed on the watch. Taught me a lesson to read the API documentation more carefully.