List of usage examples for android.os Handler Handler
@UnsupportedAppUsage public Handler(boolean async)
From source file:Main.java
/** * Get a handler object tied to the callback implemented in the activity / fragment * @return {@link Handler}// w w w. jav a2 s . co m */ public static Handler getHandlerWithCallback(Handler.Callback callback) { Handler handler = new Handler(callback); return handler; }
From source file:Main.java
/** * Run a some task on the UI thread./* ww w . java2 s . c o m*/ * * @param context The context * @param r The runnable object that will be ran on the UI thread. */ public static void runOnUiThread(Context context, Runnable r) { Handler handler = new Handler(context.getMainLooper()); handler.post(r); }
From source file:Main.java
public static Handler getMainThreadHandler() { if (mMainHandler == null) { mMainHandler = new Handler(Looper.getMainLooper()); }// w w w .j a v a 2 s . c o m return mMainHandler; }
From source file:Main.java
public static Handler getMainHandler() { if (mainHandler == null) { mainHandler = new Handler(Looper.getMainLooper()); }/*from w ww. j a v a2 s . c o m*/ return mainHandler; }
From source file:Main.java
/** * <p>Executes a given runnable on the main thread.</p> * * @param context An activity context.// w ww . ja v a 2 s . c o m * @param runnable A runnable to execute on the main thread. */ static void runOnMainThread(Context context, Runnable runnable) { Handler handler = new Handler(context.getMainLooper()); handler.post(runnable); }
From source file:Main.java
private static void showProgressDialog2AutoClose(long betweenTIme) { pd.show();//from w ww. j av a 2 s. com new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { printMultiLog("fastRequestShowProgressDialog", "auto close start"); if (pd != null) { printMultiLog("fastRequestShowProgressDialog", "do auto close"); pd.hide(); } printMultiLog("fastRequestShowProgressDialog", "auto close end"); } }, betweenTIme); }
From source file:Main.java
public static Handler getHandler() { synchronized (handlerLock) { if (handler == null) { handler = new Handler(Looper.getMainLooper()); }//w w w . j av a2 s . c o m } return handler; }
From source file:Main.java
/** * @return handler associated with the main (UI) thread. *//*ww w . j a va 2s.c o m*/ public static final Handler getMainThreadHandler() { if (sMainThreadHandler == null) { sMainThreadHandler = new Handler(Looper.getMainLooper()); } return sMainThreadHandler; }
From source file:Main.java
/** * Get a Handler that is running on a background thread. * NOTE!!! The HandlerThread that is passed as a param MUST be stopped via * handlerThread.quitSafely() or handlerThread.quit(); * @param handlerThread {@link HandlerThread}Cannot be null since this will start * the thread when it is passed. * @return {@link Handler}/*from ww w. ja va 2s. com*/ */ public static Handler getBackgroundHandler(@NonNull HandlerThread handlerThread) { handlerThread.start(); Handler handler = new Handler(handlerThread.getLooper()); return handler; }
From source file:Main.java
public static Handler getHandler() { if (handler == null) { handler = new Handler(Looper.getMainLooper()); }/*from www . j ava 2 s .c o m*/ return handler; }