Browse Source

Review `android_main()` in rcore.c (#3121)

pull/3132/head
Le Juez Victor 1 year ago
committed by GitHub
parent
commit
5e1a81555c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions
  1. +10
    -7
      src/rcore.c

+ 10
- 7
src/rcore.c View File

@ -717,17 +717,17 @@ void android_main(struct android_app *app)
char arg0[] = "raylib"; // NOTE: argv[] are mutable
CORE.Android.app = app;
// NOTE: Return codes != 0 are skipped
p">(void)main(1, (char *[]) { arg0, NULL });
// NOTE: We get the main return for exit()
kt">int ret = main(1, (char *[]) { arg0, NULL });
// Finish native activity
ANativeActivity_finish(CORE.Android.app->activity);
// Request to end the native activity
ANativeActivity_finish(app->activity);
// Android ALooper_pollAll() variables
int pollResult = 0;
int pollEvents = 0;
// Wait for app events to close
// Waiting for application events before complete finishing
while (!CORE.Android.app->destroyRequested)
{
while ((pollResult = ALooper_pollAll(0, NULL, &pollEvents, (void **)&CORE.Android.source)) >= 0)
@ -736,8 +736,11 @@ void android_main(struct android_app *app)
}
}
// WARNING: Check for deallocation and ensure no other processes are running from the application
exit(0); // Closes the application completely without going through Java
// WARNING: Make sure you free resources properly and no other process is running from Java code or other.
// NOTE: You can use JNI to call a NativeLoader method (which will call finish() from the UI thread)
// to handle the full close from Java, without using exit(0) like here.
exit(ret); // Close the application directly, without going through Java
}
// NOTE: Add this to header (if apps really need it)

Loading…
Cancel
Save