Creating a native activity with the Android native app glue
The previous recipe described how the interface defined in native_activity.h
allows us to create native activity. However, all the callbacks defined
are invoked with the main UI thread, which means we cannot do heavy processing in the callbacks.
Android SDK provides AsyncTask
, Handler
, Runnable
, Thread
, and so on, to help us handle things in the background and communicate with the main UI thread. Android NDK provides a static library named android_native_app_glue
to help us execute callback functions and handle user inputs in a separate thread. This recipe will discuss the android_native_app_glue
library in detail.
Getting ready
The android_native_app_glue
library is built on top of the native_activity.h
interface. Therefore, readers are recommended to read the Creating a native activity with the native_activity.h interface recipe before going through this one.
How to do it…
The following steps create a simple Android NDK application...