O'Reilly logo

Beginning Android Tablet Games Programming by Jeremy Kerfs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Responding to Touch

Android works on a variety of devices, so it has methods to gather all types of input. For you, however, the most important events are interactions with the touchscreen. Your number-one method is the following:

Public boolean onTouchEvent(MotionEvent event){ }

This method is inherited from the View class, and you override it in order to perform your own operations. The key aspect of this function is the parameter it contains. A MotionEvent is an object in Android that describes a variety of interactions with the tablet. You can find out a lot about the event by calling methods in the MotionEvent class. This class has many options, but the important functions are pointed out as you use them. If you’re curious, you can look ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required