Code example for FutureTask

Methods: get

     * <p> 
     * Waits for an idle sync on the main thread (see {@link Instrumentation#waitForIdle(Runnable)}) 
     * before executing this callable. 
    public <T> T runOnUiThreadAndGetTheResult(Callable<T> callable) throws Throwable {
        FutureTask<T> future = new FutureTask<T>(callable);
        try { 
            return future.get();
        } catch (ExecutionException e) {
            // Unwrap the cause of the exception and re-throw it. 
            throw e.getCause();
     * Wake up the screen, useful in tests that want or need the screen to be on. 
     * <p> 
     * This is usually called from setUp() for tests that require it.  After calling this method, 
     * {@link #releaseScreenWakeLock()} must be called, this is usually done from tearDown().