onLoad event of desktop is being called twice at restarting LL

onLoad event of desktop is being called twice at restarting LL

I set the desktop’s onLoad event handler to “Run Script”.

And that script has one line like “Android.makeNewToast(Date.now() + ” onLoad…”, true).show();

If I restart LL, then two toast messages are show with different date value.

Because it’s too weird, I tested it in newly installed LL in a virtual machine. However the same result was happened with successive two toast. That means onLoad was called twice at restarting LL.

Its bug? or my bad luck?

]]>

4 Commentsto onLoad event of desktop is being called twice at restarting LL

  1. Anonymous says:

    < ![CDATA[

    I can reproduce it too

    ]]>

  2. Anonymous says:

    < ![CDATA[

    If seen this before. not sure if I’ve seen it in all versions. But I’d call it a bug.

    ]]>

  3. Anonymous says:

    < ![CDATA[

    That’s annoying. This is happening because there are two components listening for this event and reacting to it: the foreground one (the activity) and the background one (the app). I believe both need to be preserved. In that situation the event source could indeed help, although this is still rather cumbersome.

    ]]>

  4. Anonymous says:

    < ![CDATA[

    FYI: Previously I used a hack for preventing double onLoad call, which uses script tag and event time. If two call time is less than some seconds, second call was ignored.



    But after seeing Pierre Hébert comment, I fiddled some. It’s resultant hack. (event sources were both same)



    //onLoad


    var context = LL.getContext();


    if (context == context.getApplicationContext()) {


      return; // exit.


    }


    // real onLoad routines from here.



    //==============



    At first run, LL.getContext() returned LLAppExtreme (not exact)


    Successive second run returned Activties.Dashboard (not exact)


    So,


    we can use if(context == context.getApplicationContext()) { return; }


    or if(context != context.getApplicationContext()) { return; }


    as our purpose.



    I selected the first one, bc I want to run onLoad routines after double onLoad call is finished.

    ]]>

Leave a Reply

Your email address will not be published. Required fields are marked *