post On Ui Thread - Android java.lang

Android examples for java.lang:Thread

Description

post On Ui Thread

Demo Code


//package com.java2s;
import android.os.Handler;
import android.os.Looper;

public class Main {
    public static void postOnUiThread(Runnable action, long delayMillis) {
        if (delayMillis > 0) {
            new Handler(Looper.getMainLooper()).postDelayed(action,
                    delayMillis);//from   www.  j a va2s.c  o  m
        } else {
            postOnUiThread(action);
        }
    }

    public static void postOnUiThread(Runnable action) {
        new Handler(Looper.getMainLooper()).post(action);
    }
}

Related Tutorials