Skip to content

Commit

Permalink
Android: Handle SDL3 symbol name to retrieve current JNIEnv and activ…
Browse files Browse the repository at this point in the history
…ity.
  • Loading branch information
MikuAuahDark committed Oct 13, 2024
1 parent 678018b commit 5b6ecab
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/android/AndroidClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ AndroidClient::AndroidClient()
: HTTPSClient()
{
LibraryLoader::handle *library = LibraryLoader::GetCurrentProcessHandle();
// Look for SDL_AndroidGetJNIEnv
LibraryLoader::LoadSymbol(SDL_AndroidGetJNIEnv, library, "SDL_AndroidGetJNIEnv");
// Look for SDL_AndroidGetActivity
LibraryLoader::LoadSymbol(SDL_AndroidGetActivity, library, "SDL_AndroidGetActivity");

// Look for SDL_GetAndroidJNIEnv and SDL_GetAndroidActivity (SDL3)
if (
!LibraryLoader::LoadSymbol(SDL_AndroidGetJNIEnv, library, "SDL_GetAndroidJNIEnv") &&
!LibraryLoader::LoadSymbol(SDL_AndroidGetActivity, library, "SDL_GetAndroidActivity")
)
{
// Probably running SDL2.
LibraryLoader::LoadSymbol(SDL_AndroidGetJNIEnv, library, "SDL_AndroidGetJNIEnv");
LibraryLoader::LoadSymbol(SDL_AndroidGetActivity, library, "SDL_AndroidGetActivity");
}
}

bool AndroidClient::valid() const
Expand Down

0 comments on commit 5b6ecab

Please sign in to comment.