Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

public class Main {
    private static Handler sHandler = new Handler(Looper.getMainLooper());

    public static void callOnMainThread(Runnable runnable) {
        if (!isMainThread()) {
            sHandler.post(runnable);
            return;
        }
        runnable.run();
    }

    public static boolean isMainThread() {
        return Thread.currentThread() == Looper.getMainLooper().getThread();
    }
}