MotionPredictor


public final class MotionPredictor
extends Object

java.lang.Object
   ↳ android.view.MotionPredictor


Calculate motion predictions. Feed motion events to this class in order to generate predicted future events. The prediction functionality may not be available on all devices: check if a specific source is supported on a given input device using isPredictionAvailable(int, int). Send all of the events that were received from the system to record(MotionEvent) to generate complete, accurate predictions from predict(long). When processing the returned predictions, make sure to consider all of the historical samples.

Summary

Public constructors

MotionPredictor(Context context)

Create a new MotionPredictor for the provided Context.

Public methods

boolean isPredictionAvailable(int deviceId, int source)

Check whether a device supports motion predictions for a given source type.

MotionEvent predict(long predictionTimeNanos)

Get a predicted event for the gesture that has been provided to record(MotionEvent).

void record(MotionEvent event)

Record a movement so that in the future, a prediction for the current gesture can be generated.

Inherited methods