FileDocCategorySizeDatePackage
EventsCommand.javaAPI DocAndroid 5.1 API2448Thu Mar 12 22:22:08 GMT 2015com.android.commands.uiautomator

EventsCommand

public class EventsCommand extends com.android.commands.uiautomator.Launcher.Command
Implementation of the events subcommand Prints out accessibility events until process is stopped.

Fields Summary
private Object
mQuitLock
Constructors Summary
public EventsCommand()


      
        super("events");
    
Methods Summary
public java.lang.StringdetailedOptions()

        return null;
    
public voidrun(java.lang.String[] args)

        UiAutomationShellWrapper automationWrapper = new UiAutomationShellWrapper();
        automationWrapper.connect();
        automationWrapper.getUiAutomation().setOnAccessibilityEventListener(
                new OnAccessibilityEventListener() {
            @Override
            public void onAccessibilityEvent(AccessibilityEvent event) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm:ss.SSS");
                System.out.println(String.format("%s %s",
                        formatter.format(new Date()), event.toString()));
            }
        });
        // there's really no way to stop, essentially we just block indefinitely here and wait
        // for user to press Ctrl+C
        synchronized (mQuitLock) {
            try {
                mQuitLock.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        automationWrapper.disconnect();
    
public java.lang.StringshortHelp()

        return "prints out accessibility events until terminated";