Time for action – handling Activity events
We are not done yet. Let's continue our example to handle activity events and log them to the LogCat view:
Continue editing
jni/EventLoop.cpp
. Implementactivate()
anddeactivate()
.Check both activity states before notifying the listener (to avoid untimely triggering). We consider an activity as activated only if a display window is available:... void EventLoop::activate() { // Enables activity only if a window is available. if ((!mEnabled) && (mApplication->window != NULL)) { mQuit = false; mEnabled = true; if (mActivityHandler.onActivate() != STATUS_OK) { goto ERROR; } } return; ERROR: mQuit = true; deactivate(); ANativeActivity_finish(mApplication->activity); } void EventLoop::deactivate() { if (mEnabled) { mActivityHandler.onDeactivate(); mEnabled = false; } } ...
Route activity events from the static callback
callback_appEvent()
to the member...