Skip to content

Most visited

Recently visited

navigation
added in version 22.1.0
belongs to Maven artifact com.android.support:support-compat:27.0.0

MotionEventCompat

public final class MotionEventCompat
extends Object

java.lang.Object
   ↳ android.support.v4.view.MotionEventCompat


Helper for accessing features in MotionEvent.

Summary

Constants

int ACTION_HOVER_ENTER

This constant was deprecated in API level 26.1.0. Use ACTION_HOVER_ENTER directly.

int ACTION_HOVER_EXIT

This constant was deprecated in API level 26.1.0. Use ACTION_HOVER_EXIT directly.

int ACTION_HOVER_MOVE

This constant was deprecated in API level 26.1.0. Use ACTION_HOVER_MOVE directly.

int ACTION_MASK

This constant was deprecated in API level 26.1.0. Use ACTION_MASK directly.

int ACTION_POINTER_DOWN

This constant was deprecated in API level 26.1.0. Use ACTION_POINTER_DOWN directly.

int ACTION_POINTER_INDEX_MASK

This constant was deprecated in API level 26.1.0. Use ACTION_POINTER_INDEX_MASK directly.

int ACTION_POINTER_INDEX_SHIFT

This constant was deprecated in API level 26.1.0. Use ACTION_POINTER_INDEX_SHIFT directly.

int ACTION_POINTER_UP

This constant was deprecated in API level 26.1.0. Use ACTION_POINTER_UP directly.

int ACTION_SCROLL

This constant was deprecated in API level 26.1.0. Use ACTION_SCROLL directly.

int AXIS_BRAKE

This constant was deprecated in API level 26.1.0. Use AXIS_BRAKE directly.

int AXIS_DISTANCE

This constant was deprecated in API level 26.1.0. Use AXIS_DISTANCE directly.

int AXIS_GAS

This constant was deprecated in API level 26.1.0. Use AXIS_GAS directly.

int AXIS_GENERIC_1

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_1 directly.

int AXIS_GENERIC_10

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_10 directly.

int AXIS_GENERIC_11

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_11 directly.

int AXIS_GENERIC_12

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_12 directly.

int AXIS_GENERIC_13

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_13 directly.

int AXIS_GENERIC_14

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_14 directly.

int AXIS_GENERIC_15

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_15 directly.

int AXIS_GENERIC_16

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_16 directly.

int AXIS_GENERIC_2

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_2 directly.

int AXIS_GENERIC_3

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_3 directly.

int AXIS_GENERIC_4

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_4 directly.

int AXIS_GENERIC_5

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_5 directly.

int AXIS_GENERIC_6

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_6 directly.

int AXIS_GENERIC_7

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_7 directly.

int AXIS_GENERIC_8

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_8 directly.

int AXIS_GENERIC_9

This constant was deprecated in API level 26.1.0. Use AXIS_GENERIC_9 directly.

int AXIS_HAT_X

This constant was deprecated in API level 26.1.0. Use AXIS_HAT_X directly.

int AXIS_HAT_Y

This constant was deprecated in API level 26.1.0. Use AXIS_HAT_Y directly.

int AXIS_HSCROLL

This constant was deprecated in API level 26.1.0. Use AXIS_HSCROLL directly.

int AXIS_LTRIGGER

This constant was deprecated in API level 26.1.0. Use AXIS_LTRIGGER directly.

int AXIS_ORIENTATION

This constant was deprecated in API level 26.1.0. Use AXIS_ORIENTATION directly.

int AXIS_PRESSURE

This constant was deprecated in API level 26.1.0. Use AXIS_PRESSURE directly.

int AXIS_RELATIVE_X

Synonym for AXIS_RELATIVE_X.

int AXIS_RELATIVE_Y

Synonym for AXIS_RELATIVE_Y.

int AXIS_RTRIGGER

This constant was deprecated in API level 26.1.0. Use AXIS_RTRIGGER directly.

int AXIS_RUDDER

This constant was deprecated in API level 26.1.0. Use AXIS_RUDDER directly.

int AXIS_RX

This constant was deprecated in API level 26.1.0. Use AXIS_RX directly.

int AXIS_RY

This constant was deprecated in API level 26.1.0. Use AXIS_RY directly.

int AXIS_RZ

This constant was deprecated in API level 26.1.0. Use AXIS_RZ directly.

int AXIS_SCROLL

Synonym for AXIS_SCROLL.

int AXIS_SIZE

This constant was deprecated in API level 26.1.0. Use AXIS_SIZE directly.

int AXIS_THROTTLE

This constant was deprecated in API level 26.1.0. Use AXIS_THROTTLE directly.

int AXIS_TILT

This constant was deprecated in API level 26.1.0. Use AXIS_TILT directly.

int AXIS_TOOL_MAJOR

This constant was deprecated in API level 26.1.0. Use AXIS_TOOL_MAJOR directly.

int AXIS_TOOL_MINOR

This constant was deprecated in API level 26.1.0. Use AXIS_TOOL_MINOR directly.

int AXIS_TOUCH_MAJOR

This constant was deprecated in API level 26.1.0. Use AXIS_TOUCH_MAJOR directly.

int AXIS_TOUCH_MINOR

This constant was deprecated in API level 26.1.0. Use AXIS_TOUCH_MINOR directly.

int AXIS_VSCROLL

This constant was deprecated in API level 26.1.0. Use AXIS_VSCROLL directly.

int AXIS_WHEEL

This constant was deprecated in API level 26.1.0. Use AXIS_WHEEL directly.

int AXIS_X

This constant was deprecated in API level 26.1.0. Use AXIS_X directly.

int AXIS_Y

This constant was deprecated in API level 26.1.0. Use AXIS_Y directly.

int AXIS_Z

This constant was deprecated in API level 26.1.0. Use AXIS_Z directly.

int BUTTON_PRIMARY

This constant was deprecated in API level 26.1.0. Use BUTTON_PRIMARY directly.

Public methods

static int findPointerIndex(MotionEvent event, int pointerId)

This method was deprecated in API level 25.1.0. Call findPointerIndex(int) directly. This method will be removed in a future release.

static int getActionIndex(MotionEvent event)

This method was deprecated in API level 26.1.0. Call getActionIndex() directly. This method will be removed in a future release.

static int getActionMasked(MotionEvent event)

This method was deprecated in API level 26.1.0. Call getAction() directly. This method will be removed in a future release.

static float getAxisValue(MotionEvent event, int axis)

This method was deprecated in API level 26.1.0. Call getAxisValue(int) directly. This method will be removed in a future release.

static float getAxisValue(MotionEvent event, int axis, int pointerIndex)

This method was deprecated in API level 26.1.0. Call getAxisValue(int, int) directly. This method will be removed in a future release.

static int getButtonState(MotionEvent event)

This method was deprecated in API level 26.1.0. Call getButtonState() directly. This method will be removed in a future release.

static int getPointerCount(MotionEvent event)

This method was deprecated in API level 25.1.0. Call getPointerCount() directly. This method will be removed in a future release.

static int getPointerId(MotionEvent event, int pointerIndex)

This method was deprecated in API level 25.1.0. Call getPointerId(int) directly. This method will be removed in a future release.

static int getSource(MotionEvent event)

This method was deprecated in API level 25.1.0. Call getSource() directly. This method will be removed in a future release.

static float getX(MotionEvent event, int pointerIndex)

This method was deprecated in API level 25.1.0. Call getX() directly. This method will be removed in a future release.

static float getY(MotionEvent event, int pointerIndex)

This method was deprecated in API level 25.1.0. Call getY() directly. This method will be removed in a future release.

static boolean isFromSource(MotionEvent event, int source)

Determines whether the event is from the given source.

Inherited methods

From class java.lang.Object

Constants

ACTION_HOVER_ENTER

added in version 22.1.0
int ACTION_HOVER_ENTER

This constant was deprecated in API level 26.1.0.
Use ACTION_HOVER_ENTER directly.

Synonym for ACTION_HOVER_ENTER.

Constant Value: 9 (0x00000009)

ACTION_HOVER_EXIT

added in version 22.1.0
int ACTION_HOVER_EXIT

This constant was deprecated in API level 26.1.0.
Use ACTION_HOVER_EXIT directly.

Synonym for ACTION_HOVER_EXIT.

Constant Value: 10 (0x0000000a)

ACTION_HOVER_MOVE

added in version 22.1.0
int ACTION_HOVER_MOVE

This constant was deprecated in API level 26.1.0.
Use ACTION_HOVER_MOVE directly.

Synonym for ACTION_HOVER_MOVE.

Constant Value: 7 (0x00000007)

ACTION_MASK

added in version 22.1.0
int ACTION_MASK

This constant was deprecated in API level 26.1.0.
Use ACTION_MASK directly.

Synonym for ACTION_MASK.

Constant Value: 255 (0x000000ff)

ACTION_POINTER_DOWN

added in version 22.1.0
int ACTION_POINTER_DOWN

This constant was deprecated in API level 26.1.0.
Use ACTION_POINTER_DOWN directly.

Synonym for ACTION_POINTER_DOWN.

Constant Value: 5 (0x00000005)

ACTION_POINTER_INDEX_MASK

added in version 22.1.0
int ACTION_POINTER_INDEX_MASK

This constant was deprecated in API level 26.1.0.
Use ACTION_POINTER_INDEX_MASK directly.

Synonym for ACTION_POINTER_INDEX_MASK.

Constant Value: 65280 (0x0000ff00)

ACTION_POINTER_INDEX_SHIFT

added in version 22.1.0
int ACTION_POINTER_INDEX_SHIFT

This constant was deprecated in API level 26.1.0.
Use ACTION_POINTER_INDEX_SHIFT directly.

Synonym for ACTION_POINTER_INDEX_SHIFT.

Constant Value: 8 (0x00000008)

ACTION_POINTER_UP

added in version 22.1.0
int ACTION_POINTER_UP

This constant was deprecated in API level 26.1.0.
Use ACTION_POINTER_UP directly.

Synonym for ACTION_POINTER_UP.

Constant Value: 6 (0x00000006)

ACTION_SCROLL

added in version 22.1.0
int ACTION_SCROLL

This constant was deprecated in API level 26.1.0.
Use ACTION_SCROLL directly.

Synonym for ACTION_SCROLL.

Constant Value: 8 (0x00000008)

AXIS_BRAKE

added in version 22.1.0
int AXIS_BRAKE

This constant was deprecated in API level 26.1.0.
Use AXIS_BRAKE directly.

Synonym for AXIS_BRAKE.

Constant Value: 23 (0x00000017)

AXIS_DISTANCE

added in version 22.1.0
int AXIS_DISTANCE

This constant was deprecated in API level 26.1.0.
Use AXIS_DISTANCE directly.

Synonym for AXIS_DISTANCE.

Constant Value: 24 (0x00000018)

AXIS_GAS

added in version 22.1.0
int AXIS_GAS

This constant was deprecated in API level 26.1.0.
Use AXIS_GAS directly.

Synonym for AXIS_GAS.

Constant Value: 22 (0x00000016)

AXIS_GENERIC_1

added in version 22.1.0
int AXIS_GENERIC_1

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_1 directly.

Synonym for AXIS_GENERIC_1.

Constant Value: 32 (0x00000020)

AXIS_GENERIC_10

added in version 22.1.0
int AXIS_GENERIC_10

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_10 directly.

Synonym for AXIS_GENERIC_10.

Constant Value: 41 (0x00000029)

AXIS_GENERIC_11

added in version 22.1.0
int AXIS_GENERIC_11

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_11 directly.

Synonym for AXIS_GENERIC_11.

Constant Value: 42 (0x0000002a)

AXIS_GENERIC_12

added in version 22.1.0
int AXIS_GENERIC_12

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_12 directly.

Synonym for AXIS_GENERIC_12.

Constant Value: 43 (0x0000002b)

AXIS_GENERIC_13

added in version 22.1.0
int AXIS_GENERIC_13

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_13 directly.

Synonym for AXIS_GENERIC_13.

Constant Value: 44 (0x0000002c)

AXIS_GENERIC_14

added in version 22.1.0
int AXIS_GENERIC_14

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_14 directly.

Synonym for AXIS_GENERIC_14.

Constant Value: 45 (0x0000002d)

AXIS_GENERIC_15

added in version 22.1.0
int AXIS_GENERIC_15

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_15 directly.

Synonym for AXIS_GENERIC_15.

Constant Value: 46 (0x0000002e)

AXIS_GENERIC_16

added in version 22.1.0
int AXIS_GENERIC_16

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_16 directly.

Synonym for AXIS_GENERIC_16.

Constant Value: 47 (0x0000002f)

AXIS_GENERIC_2

added in version 22.1.0
int AXIS_GENERIC_2

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_2 directly.

Synonym for AXIS_GENERIC_2.

Constant Value: 33 (0x00000021)

AXIS_GENERIC_3

added in version 22.1.0
int AXIS_GENERIC_3

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_3 directly.

Synonym for AXIS_GENERIC_3.

Constant Value: 34 (0x00000022)

AXIS_GENERIC_4

added in version 22.1.0
int AXIS_GENERIC_4

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_4 directly.

Synonym for AXIS_GENERIC_4.

Constant Value: 35 (0x00000023)

AXIS_GENERIC_5

added in version 22.1.0
int AXIS_GENERIC_5

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_5 directly.

Synonym for AXIS_GENERIC_5.

Constant Value: 36 (0x00000024)

AXIS_GENERIC_6

added in version 22.1.0
int AXIS_GENERIC_6

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_6 directly.

Synonym for AXIS_GENERIC_6.

Constant Value: 37 (0x00000025)

AXIS_GENERIC_7

added in version 22.1.0
int AXIS_GENERIC_7

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_7 directly.

Synonym for AXIS_GENERIC_7.

Constant Value: 38 (0x00000026)

AXIS_GENERIC_8

added in version 22.1.0
int AXIS_GENERIC_8

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_8 directly.

Synonym for AXIS_GENERIC_8.

Constant Value: 39 (0x00000027)

AXIS_GENERIC_9

added in version 22.1.0
int AXIS_GENERIC_9

This constant was deprecated in API level 26.1.0.
Use AXIS_GENERIC_9 directly.

Synonym for AXIS_GENERIC_9.

Constant Value: 40 (0x00000028)

AXIS_HAT_X

added in version 22.1.0
int AXIS_HAT_X

This constant was deprecated in API level 26.1.0.
Use AXIS_HAT_X directly.

Synonym for AXIS_HAT_X.

Constant Value: 15 (0x0000000f)

AXIS_HAT_Y

added in version 22.1.0
int AXIS_HAT_Y

This constant was deprecated in API level 26.1.0.
Use AXIS_HAT_Y directly.

Synonym for AXIS_HAT_Y.

Constant Value: 16 (0x00000010)

AXIS_HSCROLL

added in version 22.1.0
int AXIS_HSCROLL

This constant was deprecated in API level 26.1.0.
Use AXIS_HSCROLL directly.

Synonym for AXIS_HSCROLL.

Constant Value: 10 (0x0000000a)

AXIS_LTRIGGER

added in version 22.1.0
int AXIS_LTRIGGER

This constant was deprecated in API level 26.1.0.
Use AXIS_LTRIGGER directly.

Synonym for AXIS_LTRIGGER.

Constant Value: 17 (0x00000011)

AXIS_ORIENTATION

added in version 22.1.0
int AXIS_ORIENTATION

This constant was deprecated in API level 26.1.0.
Use AXIS_ORIENTATION directly.

Synonym for AXIS_ORIENTATION.

Constant Value: 8 (0x00000008)

AXIS_PRESSURE

added in version 22.1.0
int AXIS_PRESSURE

This constant was deprecated in API level 26.1.0.
Use AXIS_PRESSURE directly.

Synonym for AXIS_PRESSURE.

Constant Value: 2 (0x00000002)

AXIS_RELATIVE_X

added in version 24.1.0
int AXIS_RELATIVE_X

Synonym for AXIS_RELATIVE_X.

Constant Value: 27 (0x0000001b)

AXIS_RELATIVE_Y

added in version 24.1.0
int AXIS_RELATIVE_Y

Synonym for AXIS_RELATIVE_Y.

Constant Value: 28 (0x0000001c)

AXIS_RTRIGGER

added in version 22.1.0
int AXIS_RTRIGGER

This constant was deprecated in API level 26.1.0.
Use AXIS_RTRIGGER directly.

Synonym for AXIS_RTRIGGER.

Constant Value: 18 (0x00000012)

AXIS_RUDDER

added in version 22.1.0
int AXIS_RUDDER

This constant was deprecated in API level 26.1.0.
Use AXIS_RUDDER directly.

Synonym for AXIS_RUDDER.

Constant Value: 20 (0x00000014)

AXIS_RX

added in version 22.1.0
int AXIS_RX

This constant was deprecated in API level 26.1.0.
Use AXIS_RX directly.

Synonym for AXIS_RX.

Constant Value: 12 (0x0000000c)

AXIS_RY

added in version 22.1.0
int AXIS_RY

This constant was deprecated in API level 26.1.0.
Use AXIS_RY directly.

Synonym for AXIS_RY.

Constant Value: 13 (0x0000000d)

AXIS_RZ

added in version 22.1.0
int AXIS_RZ

This constant was deprecated in API level 26.1.0.
Use AXIS_RZ directly.

Synonym for AXIS_RZ.

Constant Value: 14 (0x0000000e)

AXIS_SCROLL

added in version 26.1.0
int AXIS_SCROLL

Synonym for AXIS_SCROLL.

Constant Value: 26 (0x0000001a)

AXIS_SIZE

added in version 22.1.0
int AXIS_SIZE

This constant was deprecated in API level 26.1.0.
Use AXIS_SIZE directly.

Synonym for AXIS_SIZE.

Constant Value: 3 (0x00000003)

AXIS_THROTTLE

added in version 22.1.0
int AXIS_THROTTLE

This constant was deprecated in API level 26.1.0.
Use AXIS_THROTTLE directly.

Synonym for AXIS_THROTTLE.

Constant Value: 19 (0x00000013)

AXIS_TILT

added in version 22.1.0
int AXIS_TILT

This constant was deprecated in API level 26.1.0.
Use AXIS_TILT directly.

Synonym for AXIS_TILT.

Constant Value: 25 (0x00000019)

AXIS_TOOL_MAJOR

added in version 22.1.0
int AXIS_TOOL_MAJOR

This constant was deprecated in API level 26.1.0.
Use AXIS_TOOL_MAJOR directly.

Synonym for AXIS_TOOL_MAJOR.

Constant Value: 6 (0x00000006)

AXIS_TOOL_MINOR

added in version 22.1.0
int AXIS_TOOL_MINOR

This constant was deprecated in API level 26.1.0.
Use AXIS_TOOL_MINOR directly.

Synonym for AXIS_TOOL_MINOR.

Constant Value: 7 (0x00000007)

AXIS_TOUCH_MAJOR

added in version 22.1.0
int AXIS_TOUCH_MAJOR

This constant was deprecated in API level 26.1.0.
Use AXIS_TOUCH_MAJOR directly.

Synonym for AXIS_TOUCH_MAJOR.

Constant Value: 4 (0x00000004)

AXIS_TOUCH_MINOR

added in version 22.1.0
int AXIS_TOUCH_MINOR

This constant was deprecated in API level 26.1.0.
Use AXIS_TOUCH_MINOR directly.

Synonym for AXIS_TOUCH_MINOR.

Constant Value: 5 (0x00000005)

AXIS_VSCROLL

added in version 22.1.0
int AXIS_VSCROLL

This constant was deprecated in API level 26.1.0.
Use AXIS_VSCROLL directly.

Synonym for AXIS_VSCROLL.

Constant Value: 9 (0x00000009)

AXIS_WHEEL

added in version 22.1.0
int AXIS_WHEEL

This constant was deprecated in API level 26.1.0.
Use AXIS_WHEEL directly.

Synonym for AXIS_WHEEL.

Constant Value: 21 (0x00000015)

AXIS_X

added in version 22.1.0
int AXIS_X

This constant was deprecated in API level 26.1.0.
Use AXIS_X directly.

Synonym for AXIS_X.

Constant Value: 0 (0x00000000)

AXIS_Y

added in version 22.1.0
int AXIS_Y

This constant was deprecated in API level 26.1.0.
Use AXIS_Y directly.

Synonym for AXIS_Y.

Constant Value: 1 (0x00000001)

AXIS_Z

added in version 22.1.0
int AXIS_Z

This constant was deprecated in API level 26.1.0.
Use AXIS_Z directly.

Synonym for AXIS_Z.

Constant Value: 11 (0x0000000b)

BUTTON_PRIMARY

added in version 24.1.0
int BUTTON_PRIMARY

This constant was deprecated in API level 26.1.0.
Use BUTTON_PRIMARY directly.

Synonym for BUTTON_PRIMARY.

Constant Value: 1 (0x00000001)

Public methods

findPointerIndex

added in version 22.1.0
int findPointerIndex (MotionEvent event, 
                int pointerId)

This method was deprecated in API level 25.1.0.
Call findPointerIndex(int) directly. This method will be removed in a future release.

Call findPointerIndex(int).

Parameters
event MotionEvent

pointerId int

Returns
int

getActionIndex

added in version 22.1.0
int getActionIndex (MotionEvent event)

This method was deprecated in API level 26.1.0.
Call getActionIndex() directly. This method will be removed in a future release.

Call getAction(), returning only the pointer index portion.

Parameters
event MotionEvent

Returns
int

getActionMasked

added in version 22.1.0
int getActionMasked (MotionEvent event)

This method was deprecated in API level 26.1.0.
Call getAction() directly. This method will be removed in a future release.

Call getAction(), returning only the ACTION_MASK portion.

Parameters
event MotionEvent

Returns
int

getAxisValue

added in version 22.1.0
float getAxisValue (MotionEvent event, 
                int axis)

This method was deprecated in API level 26.1.0.
Call getAxisValue(int) directly. This method will be removed in a future release.

Get axis value for the first pointer index (may be an arbitrary pointer identifier).

Parameters
event MotionEvent

axis int: The axis identifier for the axis value to retrieve.

Returns
float

See also:

getAxisValue

added in version 22.1.0
float getAxisValue (MotionEvent event, 
                int axis, 
                int pointerIndex)

This method was deprecated in API level 26.1.0.
Call getAxisValue(int, int) directly. This method will be removed in a future release.

Returns the value of the requested axis for the given pointer index (use getPointerId(MotionEvent, int) to find the pointer identifier for this index).

Parameters
event MotionEvent

axis int: The axis identifier for the axis value to retrieve.

pointerIndex int: Raw index of pointer to retrieve. Value may be from 0 (the first pointer that is down) to getPointerCount(MotionEvent)-1.

Returns
float The value of the axis, or 0 if the axis is not available.

See also:

getButtonState

added in version 24.1.0
int getButtonState (MotionEvent event)

This method was deprecated in API level 26.1.0.
Call getButtonState() directly. This method will be removed in a future release.

Parameters
event MotionEvent

Returns
int

getPointerCount

added in version 22.1.0
int getPointerCount (MotionEvent event)

This method was deprecated in API level 25.1.0.
Call getPointerCount() directly. This method will be removed in a future release.

The number of pointers of data contained in this event. Always

Parameters
event MotionEvent

Returns
int

getPointerId

added in version 22.1.0
int getPointerId (MotionEvent event, 
                int pointerIndex)

This method was deprecated in API level 25.1.0.
Call getPointerId(int) directly. This method will be removed in a future release.

Call getPointerId(int).

Parameters
event MotionEvent

pointerIndex int

Returns
int

getSource

added in version 22.1.0
int getSource (MotionEvent event)

This method was deprecated in API level 25.1.0.
Call getSource() directly. This method will be removed in a future release.

Gets the source of the event.

Parameters
event MotionEvent

Returns
int The event source or SOURCE_UNKNOWN if unknown.

getX

added in version 22.1.0
float getX (MotionEvent event, 
                int pointerIndex)

This method was deprecated in API level 25.1.0.
Call getX() directly. This method will be removed in a future release.

Call getX(int).

Parameters
event MotionEvent

pointerIndex int

Returns
float

getY

added in version 22.1.0
float getY (MotionEvent event, 
                int pointerIndex)

This method was deprecated in API level 25.1.0.
Call getY() directly. This method will be removed in a future release.

Call getY(int).

Parameters
event MotionEvent

pointerIndex int

Returns
float

isFromSource

added in version 24.1.0
boolean isFromSource (MotionEvent event, 
                int source)

Determines whether the event is from the given source.

Parameters
event MotionEvent

source int: The input source to check against.

Returns
boolean Whether the event is from the given source.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)