Skip to content Skip to sidebar Skip to footer

Why Doesn't This Motionevent Simulation Work?

In one of the views in an exercise app, am trying to perform text selection programmatically. I am able to (programmatically) enter 'text selection mode', which is visually indicat

Solution 1:

For lack of a working solution, I can only conclude that what I have been trying to accomplish isn't possible on the Android, for reasons of security. An explanation can be found in the following link: How to send synthesized MotionEvent through the system?

Solution 2:

The OnTouchListener is called inside the View from dispatchTouchEvent which in turn has been called from ViewGroup or a TouchDelegate. If you call the listener from your view it simply does what ever you have there and then returns. It doesn't magically delegate the touch event anywhere.

Instead Call dispatchTouchEvent() on your view to get the correct result.

For unit testing your application behavior on text selection etc. See http://developer.android.com/resources/tutorials/testing/activity_test.html

Post a Comment for "Why Doesn't This Motionevent Simulation Work?"