Force flushing MessageQueue of UiThread android

972 Views Asked by At

I want to flush content to the display as soon as possible but my setup code which is want to have on the UI Thread is taking too long. There is nothing rendered on the screen until everything is done.

So if i do a View.postDelayed(Runnable, long) with a delay of at least 100 millis the layout gets rendered before the setup starts. what i want to do is having the layout rendered on the screen at onResume (for instance) and then continue the setup.

What I am looking for is a way to make sure the Looper empties it's MessageQueue and renders everything until this method is called, and then continues processing messages.

I probably should run the setup in a background thread, but this complicates other things.

0

There are 0 best solutions below