Until now, we have not handled any user interaction except the BACK button on Android. In this recipe, we show how to process multi-touch events on Android.
You should be familiar with the concepts of multi-touch input handling. In Java, Android multi-touch events are delivered inside the MotionEvent
class, an instance of which is passed as a parameter to the onTouchEvent()
method of your Activity
class. The MotionEvent
class contains all the information of the currently active and released touches. In order to pass this information to our native code, we convert a single event carrying multiple touches into a series of events holding data for a single touch. This keeps the JNI interoperation simple and enables easy porting of our code.