1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| #include "com_lb_test_jni_JNITest.h"
JNIEXPORT jstring JNICALL Java_com_lb_test_jni_JNITest_nativeMethod(JNIEnv *env, jobject obj, jstring username, jstring password) { const char *c_username = env->GetStringUTFChars(username, NULL); const char *c_password = env->GetStringUTFChars(password, NULL);
char result[256]; snprintf(result, sizeof(result), "Hello, %s! Your password is %s.", c_username, c_password);
env->ReleaseStringUTFChars(username, c_username); env->ReleaseStringUTFChars(password, c_password);
return env->NewStringUTF(result); }
|