Created
June 10, 2012 14:48
-
-
Save tshirtman/2906019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void android_set_env(char *key, char *value) { | |
static JNIEnv *env = NULL; | |
static jclass *cls = NULL; | |
static jmethodID mid = NULL; | |
if (env == NULL) { | |
env = SDL_ANDROID_GetJNIEnv(); | |
aassert(env); | |
cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); | |
aassert(cls); | |
mid = (*env)->GetStaticMethodID(env, cls, "nativeSetEnv", "(Ljava/lang/String;Ljava/lang/String)V"); | |
aassert(mid); | |
} | |
(*env)->CallStaticVoidMethod( | |
env, cls, mid, | |
(*env)->NewStringUTF(env, key), | |
(*env)->NewStringUTF(env, value) | |
); | |
} | |
char* android_get_env(char *key) { | |
static JNIEnv *env = NULL; | |
static jclass *cls = NULL; | |
static jmethodID mid = NULL; | |
jobject jreading; | |
if (env == NULL) { | |
env = SDL_ANDROID_GetJNIEnv(); | |
aassert(env); | |
cls = (*env)->FindClass(env, "org/renpy/android/SDLSurfaceView"); | |
aassert(cls); | |
mid = (*env)->GetStaticMethodID(env, cls, "nativeGetEnv", "(Ljava/lang/String;)V"); | |
aassert(mid); | |
} | |
jreading = (*env)->CallStaticObjectMethod(env, cls, mid); | |
const char * reading = (*env)->GetStringUTFChars(env, jreading, 0); | |
POP_FRAME; | |
return reading; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment