Merged GameLauncher and GameActivity together

The GameActivity would not run otherwise as the App started via
GameActivity would call in love::android::getSelectedGameFile() the wrong
activity (namely GameLauncher) that was not initialized properly. Hence it
would result in a segfault.
This commit is contained in:
fysx
2014-02-14 00:56:47 +01:00
parent 5849e8d369
commit 60a58f9240
4 changed files with 99 additions and 108 deletions
+16 -16
View File
@@ -54,26 +54,26 @@ double getScreenScale()
const char* getSelectedGameFile()
{
static const char *path = NULL;
static const char *path = NULL;
if (!path) {
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameLauncher");
if (!path) {
JNIEnv *env = (JNIEnv*) SDL_AndroidGetJNIEnv();
jclass activity = env->FindClass("org/love2d/android/GameActivity");
jmethodID getGamePath = env->GetStaticMethodID(activity, "getGamePath", "()Ljava/lang/String;");
jstring gamePath = (jstring) env->CallStaticObjectMethod(activity, getGamePath);
const char *utf = env->GetStringUTFChars(gamePath, 0);
if (utf)
{
path = SDL_strdup(utf);
env->ReleaseStringUTFChars(gamePath, utf);
}
jmethodID getGamePath = env->GetStaticMethodID(activity, "getGamePath", "()Ljava/lang/String;");
jstring gamePath = (jstring) env->CallStaticObjectMethod(activity, getGamePath);
const char *utf = env->GetStringUTFChars(gamePath, 0);
if (utf)
{
path = SDL_strdup(utf);
env->ReleaseStringUTFChars(gamePath, utf);
}
env->DeleteLocalRef (gamePath);
env->DeleteLocalRef (activity);
}
env->DeleteLocalRef (gamePath);
env->DeleteLocalRef (activity);
}
return path;
return path;
}
} // android