To create a new event, you must use one of the static obtain methods of the obtain class.
The easiest way (in addition to wrapping a new event from an existing one):
static public MotionEvent obtain(long downTime, long eventTime, int action, float x, float y, int metaState) {
API docs :
Create a new MotionEvent by filling out a subset of the basic motion values. Those that are not listed here: id device (always 0), pressure and size (always 1), x and y precision (always 1), and edgeFlags (always 0).
Parameters :
downTime time (in ms) when the user first clicked the position event stream. This should be obtained from SystemClock.uptimeMillis ().eventTime time (in ms) when this particular event was generated. This should be obtained from SystemClock.uptimeMillis() .action The type of action performed is one of ACTION_DOWN , ACTION_MOVE , ACTION_UP or ACTION_CANCEL .x X coordinate of this event.y The y coordinate of this event.metaState state of any meta / modifiers that acted when the event was created.
API Document Reference
rekaszeru May 03 '11 at 8:49 a.m. 2011-05-03 08:49
source share