Example usage for android.os Handler Handler

List of usage examples for android.os Handler Handler

Introduction

In this page you can find the example usage for android.os Handler Handler.

Prototype

@UnsupportedAppUsage
public Handler(boolean async) 

Source Link

Document

Use the Looper for the current thread and set whether the handler should be asynchronous.

Usage

From source file:Main.java

public static void runOnUi(Runnable task) {
    new Handler(Looper.getMainLooper()).post(task);
}

From source file:Main.java

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

From source file:Main.java

private static void scheduleOnMainThread(Runnable r) {
    new Handler(Looper.getMainLooper()).post(r);
}

From source file:Main.java

public static void runOnUiThread(Runnable runnable) {
    new Handler(Looper.getMainLooper()).post(runnable);
}

From source file:Main.java

public static void scheduleOnMainThread(Runnable r) {
    new Handler(Looper.getMainLooper()).post(r);
}

From source file:Main.java

public static void gcDelay(long delay) {
    new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
        @Override/*w ww .j  a v  a 2s  .co  m*/
        public void run() {
            gc();
        }
    }, delay);
}

From source file:Main.java

public static void run(final Runnable runnable) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override// w  w  w  .  ja  v  a  2s  .  co m
        public void run() {
            runnable.run();
        }
    });
}

From source file:Main.java

public static void scheduleDelayedTask(Runnable task, long delay) {
    Handler handler = new Handler(Looper.getMainLooper());
    handler.postDelayed(task, delay);/*from   w  w w . j a va  2  s  .c  o m*/
}

From source file:Main.java

public static void runOnUiThread(final Runnable runnable) {
    if (Looper.myLooper() != Looper.getMainLooper()) {
        new Handler(Looper.getMainLooper()).post(runnable);
    } else {// w w  w.  jav a 2 s.c  o  m
        runnable.run();
    }
}

From source file:Main.java

public static Handler getMainHandler() {
    if (handler == null) {
        handler = new Handler(Looper.getMainLooper());
    }/* www  .  ja v  a2s  .c o m*/
    return handler;
}