Code example for HandlerThread

Methods: getLooper, isAlive, start

    private final HandlerThread mHandlerThread = new HandlerThread(HANDLER_THREAD_NAME);
    private UiAutomation mUiAutomation;
    public void connect() { 
        if (mHandlerThread.isAlive()) {
            throw new IllegalStateException("Already connected!");
        mUiAutomation = new UiAutomation(mHandlerThread.getLooper(),
                new UiAutomationConnection()); 
     * Enable or disable monkey test mode. 
     * Setting test as "monkey" indicates to some applications that a test framework is 
     * running as a "monkey" type. Such applications may choose not to perform actions that 
     * do submits so to avoid allowing monkey tests from doing harm or performing annoying 
     * actions such as dialing 911 or posting messages to public forums, etc.