Android examples for java.lang:Thread
remove Callbacks And Messages
// Copyright (c) 2012 The Chromium Authors. All rights reserved. //package com.java2s; import android.os.Handler; import android.os.Looper; public class Main { private static final Object sLock = new Object(); private static boolean sWillOverride = false; private static Handler sUiThreadHandler = null; public static void removeCallbacksAndMessages() { getUiThreadHandler().removeCallbacksAndMessages(null); }/*from w w w . ja v a 2s. c o m*/ private static Handler getUiThreadHandler() { synchronized (sLock) { if (sUiThreadHandler == null) { if (sWillOverride) { throw new RuntimeException( "Did not yet override the UI thread"); } sUiThreadHandler = new Handler(Looper.getMainLooper()); } return sUiThreadHandler; } } }