public static <T> T runOnUiThreadBlocking(Callable<T> c) {
        FutureTask<T> task = new FutureTask<>(c);
        new Handler(Looper.getMainLooper()).post(task);
        try {
            return task.get();
        } catch (InterruptedException e) {
            throw new RuntimeException("Interrupted waiting for callable", e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e.getCause());
        }
    }
Runs the supplied Callable on the main thread, returning the result. Blocks until completes.
customtabs/tests/src/android/support/customtabs/testutil/TestUtil.java