diff --git a/panda/src/android/android_main.cxx b/panda/src/android/android_main.cxx index 13895d99f6..59ba9a32a8 100644 --- a/panda/src/android/android_main.cxx +++ b/panda/src/android/android_main.cxx @@ -267,11 +267,10 @@ void android_main(struct android_app* app) { // We still need to keep an event loop going until Android gives us leave // to end the process. - int looper_id; - int events; - struct android_poll_source *source; - while ((looper_id = ALooper_pollAll(-1, nullptr, &events, (void**)&source)) >= 0) { - // Process this event, but intercept application command events. + while (!app->destroyRequested) { + int looper_id; + struct android_poll_source *source; + auto result = ALooper_pollOnce(-1, &looper_id, nullptr, (void **)&source); if (looper_id == LOOPER_ID_MAIN) { int8_t cmd = android_app_read_cmd(app); android_app_pre_exec_cmd(app, cmd); diff --git a/panda/src/android/pview_manifest.xml b/panda/src/android/pview_manifest.xml index b462e4018a..e68dce5584 100644 --- a/panda/src/android/pview_manifest.xml +++ b/panda/src/android/pview_manifest.xml @@ -8,7 +8,7 @@ - + diff --git a/panda/src/androiddisplay/androidGraphicsWindow.cxx b/panda/src/androiddisplay/androidGraphicsWindow.cxx index b3a8ae425d..eb388815d8 100644 --- a/panda/src/androiddisplay/androidGraphicsWindow.cxx +++ b/panda/src/androiddisplay/androidGraphicsWindow.cxx @@ -181,16 +181,14 @@ process_events() { GraphicsWindow::process_events(); // Read all pending events. - int looper_id; - int events; - struct android_poll_source* source; + struct android_poll_source *source; - // Loop until all events are read. - while ((looper_id = ALooper_pollAll(0, nullptr, &events, (void**)&source)) >= 0) { - // Process this event. - if (source != nullptr) { - source->process(_app, source); - } + auto result = ALooper_pollOnce(0, nullptr, nullptr, (void **)&source); + nassertv(result != ALOOPER_POLL_ERROR); + + // Process this event. + if (source != nullptr) { + source->process(_app, source); } } diff --git a/pandatool/src/deploy-stub/android_main.cxx b/pandatool/src/deploy-stub/android_main.cxx index 5aa24b53d2..b29889764e 100644 --- a/pandatool/src/deploy-stub/android_main.cxx +++ b/pandatool/src/deploy-stub/android_main.cxx @@ -297,11 +297,10 @@ void android_main(struct android_app *app) { // We still need to keep an event loop going until Android gives us leave // to end the process. - int looper_id; - int events; - struct android_poll_source *source; - while ((looper_id = ALooper_pollAll(-1, nullptr, &events, (void**)&source)) >= 0) { - // Process this event, but intercept application command events. + while (!app->destroyRequested) { + int looper_id; + struct android_poll_source *source; + auto result = ALooper_pollOnce(-1, &looper_id, nullptr, (void **)&source); if (looper_id == LOOPER_ID_MAIN) { int8_t cmd = android_app_read_cmd(app); android_app_pre_exec_cmd(app, cmd);