* The callback for native_app_glue's Activity lifecycle event queue. */
| 234 | * The callback for native_app_glue's Activity lifecycle event queue. |
| 235 | */ |
| 236 | static void engine_handle_cmd(android_app* app, int32_t cmd) { |
| 237 | auto* engine = (Engine*)app->userData; |
| 238 | // There are a lot of lifecycle events that we're ignoring here. See |
| 239 | // android_native_app_glue.h for the complete list that native_app_glue |
| 240 | // handles (which may not be complete if Activity adds new lifecycle |
| 241 | // methods!) |
| 242 | // |
| 243 | // Most applications will need to handle many more of than just this set. |
| 244 | // We're getting away with ignoring most events because this app doesn't do |
| 245 | // anything interesting. |
| 246 | switch (cmd) { |
| 247 | case APP_CMD_INIT_WINDOW: |
| 248 | // https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowcreated |
| 249 | engine->AttachWindow(); |
| 250 | break; |
| 251 | case APP_CMD_TERM_WINDOW: |
| 252 | // https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowdestroyed |
| 253 | engine->DetachWindow(); |
| 254 | break; |
| 255 | case APP_CMD_GAINED_FOCUS: |
| 256 | // https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onwindowfocuschanged |
| 257 | engine->Resume(); |
| 258 | break; |
| 259 | case APP_CMD_LOST_FOCUS: |
| 260 | // https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onwindowfocuschanged |
| 261 | engine->Pause(); |
| 262 | break; |
| 263 | default: |
| 264 | break; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | /** |
| 269 | * `android_main()` is the entry point for an app using `native_app_glue`. |
nothing calls this directly
no test coverage detected