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) ...
Get Android NDK Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.