app.Wait() and app.ShowPopup() - msg queuing issue?

439 views
Skip to first unread message

Paul Norman

unread,
May 4, 2016, 5:43:21 AM5/4/16
to DroidScript
Hi,

The following seems to process both Wait()s before the popup shows, and then dissappears too soon:

app.Wait( 1 );
app.ShowPopup("Some Text"); // should be default Long show
app.Wait( 1 );

minor Blah blahs ...

app.Exit();

Is this some quirk of the Android system's message queue prioritising, or the DroidScript bridge or something?

Is there a known work around please?

Paul

Dave Smart

unread,
May 4, 2016, 5:52:48 AM5/4/16
to androi...@googlegroups.com
Hi Paul,

the app.Wait() function blocks the main thread of the app and will prevent drawing of any controls, so the popup message cannot show it'self until the wait functions complete because it is run as an asynchronous process.

Generally you should not use the app.Wait() method as it causes unresponsive user interface behaviour, it should only be used in special circumstances. 

You should use the standard JavaScript alert() function if you want to block the thread and have things behave in a sequence (which I think you are trying to do here?)

Regards
David

Paul Norman

unread,
May 4, 2016, 8:26:43 AM5/4/16
to DroidScript
Thanks Dave,

Its a small GUI-less app called from certain other apps' Share feature (browsers and text displaying apps), I wanted a small quick message showing why somethings didn't / couldn't happen as the User may have expected.

Exit() has to be called after it so it doesn't remain open, and that prematurely kills the popup as well.

A popup followed by a single Wait() also doesnt show until the postpositioned Wait() has executed as is to be expected by what you just shared I suppise.

My double Wait() was an experiment to test whether Wait()s somehow took precedence over popups.

The message then still showed after both Wait()s were finished.

So I was looking for an unobtrusive message style - may need to try and use a timer or an alert() after all :-)

Thanks,
paul

Steve Garman

unread,
May 4, 2016, 8:34:47 AM5/4/16
to DroidScript
I normally use something like

app.ShowPopup( "snafu" );
setTimeout(app.Exit,400);

though the setTimeout often calls a function that cleans up before it exits.

Paul Norman

unread,
May 4, 2016, 12:59:57 PM5/4/16
to DroidScript
Great thanks Steve.

Paul

Reply all
Reply to author
Forward
0 new messages