O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

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

Time for action – handling touch events

Let's begin with the plumber to connect Android input event queue to our application.

  1. In the same way we created an ActivityHandler to process application events in Chapter 5, Writing a Native Application, create a class InputHandler, in a new file jni/InputHandler.hpp to process the input events. Input API is declared in android/input.h.
  2. Create a onTouchEvent() to handle touch events. These events are packaged in an AInputEvent structure defined in Android include files. Other input peripherals will be added later in this chapter:
    #ifndef _PACKT_INPUTHANDLER_HPP_ #define _PACKT_INPUTHANDLER_HPP_ #include <android/input.h> namespace packt { class InputHandler { public: virtual ~InputHandler() {}; virtual bool ...

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