Domanda

Just got some strange behaviour and needed to ask. My thought is that this runOnUiThread will run after onResume()

  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            // do stuff..
            // do stuff..
            ...runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //Drink lemonade
                }
            });
        }
            // do stuff..
            // do stuff..
    }


    @Override
    protected void onStart() {
        super.onStart();
            // do stuff..
    }

    @Override
    protected void onResume() {
        super.onResume();
            // do stuff..
    }
È stato utile?

Soluzione

From the docs:

Runs the specified action on the UI thread. If the current thread is the UI thread, then the action is executed immediately. If the current thread is not the UI thread, the action is posted to the event queue of the UI thread.

In my opinion you shouldn't call runOnUiThread() from the UI Thread because you already are on the UI Thread

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top