Detecting and handling input events at Android NDK
Input events are essential for user interaction in Android apps. This recipe discusses how to detect and handle input events in Android NDK.
Getting ready
We will further develop the example in last recipe. Please read the Managing native windows at Android NDK recipe before going through this one.
How to do it…
The following steps create a sample application, which detects and handles input events at the native code:
Create an Android application named
NativeInputs
. Set the package name ascookbook.chapter5.nativeinputs
. Please refer to the Loading native libraries and registering native methods recipe of Chapter 2, Java Native Interface, if you want more detailed instructions.Right-click on the
NativeInputs
project, select Android Tools | Add Native Support.Update
AndroidManifest.xml
. Please refer to previous recipe or the downloaded code for details. Note that the metadataandroid.app.lib_name
must have a value asNativeInputs
.Add two files...