MotionEvent event = MotionEvent.obtain( 0, // Down time SystemClock.uptimeMillis(), // Event time MotionEvent.ACTION_MOVE, // Action code 100, // X coordinate 200, // Y coordinate 0 // Pressure );
MotionEvent start = MotionEvent.obtain( System.currentTimeMillis(), System.currentTimeMillis(), MotionEvent.ACTION_DOWN, 100, 200, 0 ); MotionEvent end = MotionEvent.obtain( System.currentTimeMillis(), System.currentTimeMillis(), MotionEvent.ACTION_UP, 200, 300, 0 );This code creates two MotionEvent objects for a touch gesture that starts with an ACTION_DOWN event at (100, 200) and ends with an ACTION_UP event at (200, 300). Both of these examples are part of the android.view package library.