androidandroid-testingandroid-espressoandroid-instrumentationandroid-junit

What is touch mode and why is it important for the ActivityTestRule class?


The ActivityTestRule class takes in an initialTouchMode parameter in its constructor. This is not explained in the class reference (or anywhere online) except as follows:

initialTouchMode - true if the Activity should be placed into "touch mode" when started

What exactly does "touch mode" mean? What are the implications of setting initialTouchMode in ActivityTestRule to true or false? (I see that the default value for this parameter is false).


Solution

  • Touch mode affect how view focus and selection work.

    The touch mode is a state of the view hierarchy that depends solely on the user interaction with the phone. By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen.

    ...

    In touch mode, there is no focus and no selection.

    http://android-developers.blogspot.com/2008/12/touch-mode.html