url: patched to compile on Android.

This commit is contained in:
Ryan C. Gordon 2020-10-05 13:52:52 -04:00
parent 84f1b95008
commit 5f68812249
4 changed files with 8 additions and 1 deletions

View File

@ -2284,6 +2284,11 @@ void *SDL_AndroidGetActivity(void)
return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext);
} }
jclass Android_GetActivityClass(void)
{
return mActivityClass;
}
int SDL_GetAndroidSDKVersion(void) int SDL_GetAndroidSDKVersion(void)
{ {
static int sdk_version; static int sdk_version;

View File

@ -140,6 +140,8 @@ void Android_ActivityMutex_Lock(void);
void Android_ActivityMutex_Unlock(void); void Android_ActivityMutex_Unlock(void);
void Android_ActivityMutex_Lock_Running(void); void Android_ActivityMutex_Lock_Running(void);
jclass Android_GetActivityClass(void);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */
#ifdef __cplusplus #ifdef __cplusplus
/* *INDENT-OFF* */ /* *INDENT-OFF* */

View File

@ -18,7 +18,6 @@
misrepresented as being the original software. misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "../SDL_internal.h" #include "../SDL_internal.h"
#include "SDL_error.h" #include "SDL_error.h"

View File

@ -25,6 +25,7 @@
int int
SDL_SYS_OpenURL(const char *url) SDL_SYS_OpenURL(const char *url)
{ {
jclass mActivityClass = Android_GetActivityClass();
JNIEnv *env = Android_JNI_GetEnv(); JNIEnv *env = Android_JNI_GetEnv();
jstring jurl = (*env)->NewStringUTF(env, url); jstring jurl = (*env)->NewStringUTF(env, url);
const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl); const int ret = (*env)->CallStaticIntMethod(env, mActivityClass, midOpenURL, jurl);