Fix compilation with latest sdl2
This commit is contained in:
parent
ff2d4a950e
commit
7f9f4dc182
@ -309,22 +309,6 @@ public class SuperTuxKartActivity extends SDLActivity
|
|||||||
}
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/* Called by STK in JNI. */
|
/* 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,
|
public void fromSTKEditBox(final int widget_id, final String text,
|
||||||
final int selection_start,
|
final int selection_start,
|
||||||
final int selection_end, final int type)
|
final int selection_end, final int type)
|
||||||
|
@ -24,8 +24,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <jni.h>
|
#include "SDL_misc.h"
|
||||||
#include "SDL_system.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IOS_STK
|
#ifdef IOS_STK
|
||||||
@ -48,45 +47,7 @@ namespace Online
|
|||||||
void LinkHelper::openURL (std::string url)
|
void LinkHelper::openURL (std::string url)
|
||||||
{
|
{
|
||||||
#if defined(ANDROID)
|
#if defined(ANDROID)
|
||||||
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
|
SDL_OpenURL(url.c_str());
|
||||||
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);
|
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||||
#elif defined(IOS_STK)
|
#elif defined(IOS_STK)
|
||||||
|
Loading…
Reference in New Issue
Block a user