Fix compilation with latest sdl2

This commit is contained in:
Benau 2020-12-05 14:22:59 +08:00
parent ff2d4a950e
commit 7f9f4dc182
2 changed files with 2 additions and 57 deletions

View File

@ -309,22 +309,6 @@ public class SuperTuxKartActivity extends SDLActivity
}
// ------------------------------------------------------------------------
/* Called by STK in JNI. */
public void openURL(final String url)
{
try
{
Uri uri = Uri.parse(url);
Intent i = new Intent(Intent.ACTION_VIEW, uri);
if (i.resolveActivity(getPackageManager()) != null)
startActivity(i);
}
catch (ActivityNotFoundException e)
{
e.printStackTrace();
}
}
// ------------------------------------------------------------------------
/* Called by STK in JNI. */
public void fromSTKEditBox(final int widget_id, final String text,
final int selection_start,
final int selection_end, final int type)

View File

@ -24,8 +24,7 @@
#endif
#ifdef ANDROID
#include <jni.h>
#include "SDL_system.h"
#include "SDL_misc.h"
#endif
#ifdef IOS_STK
@ -48,45 +47,7 @@ namespace Online
void LinkHelper::openURL (std::string url)
{
#if defined(ANDROID)
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
if (env == NULL)
{
Log::error("LinkHelper",
"openURL unable to SDL_AndroidGetJNIEnv.");
return;
}
jobject native_activity = (jobject)SDL_AndroidGetActivity();
if (native_activity == NULL)
{
Log::error("LinkHelper",
"openURL unable to SDL_AndroidGetActivity.");
return;
}
jclass class_native_activity = env->GetObjectClass(native_activity);
if (class_native_activity == NULL)
{
Log::error("LinkHelper", "openURL unable to find object class.");
env->DeleteLocalRef(native_activity);
return;
}
jmethodID method_id = env->GetMethodID(class_native_activity, "openURL", "(Ljava/lang/String;)V");
if (method_id == NULL)
{
Log::error("LinkHelper", "openURL unable to find method id.");
env->DeleteLocalRef(class_native_activity);
env->DeleteLocalRef(native_activity);
return;
}
jstring url_jstring = env->NewStringUTF(url.c_str());
env->CallVoidMethod(native_activity, method_id, url_jstring);
env->DeleteLocalRef(url_jstring);
env->DeleteLocalRef(class_native_activity);
env->DeleteLocalRef(native_activity);
SDL_OpenURL(url.c_str());
#elif defined(_WIN32)
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
#elif defined(IOS_STK)