Created
June 17, 2016 06:04
-
-
Save filipproch/da6edb3268a215ecf73007039217f02c to your computer and use it in GitHub Desktop.
test creating objects in c++
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
// | |
// Created by Filip Prochazka (@filipproch) | |
// | |
#include <jni.h> | |
#ifdef __cplusplus | |
extern "C" | |
{ | |
#endif | |
JNIEXPORT void JNICALL Java_cz_filipproch_testjniobjects_MainActivity_test( JNIEnv* env, | |
jobject thiz ) { | |
jclass clazz = env->FindClass("cz/filipproch/testjniobjects/MainActivity"); | |
jmethodID callbackMethodId = env->GetMethodID(clazz, "testCallback", "(Lcz/filipproch/testjniobjects/Data;)V"); | |
jclass dataClazz = env->FindClass("cz/filipproch/testjniobjects/Data"); | |
jmethodID setInt = env->GetMethodID(dataClazz, "setInt", "(I)V"); | |
jmethodID constructor = env->GetMethodID(dataClazz, "<init>", "()V"); | |
jobject dataObject = env->NewObject(dataClazz, constructor); | |
env->CallVoidMethod(dataObject, setInt, 55); | |
env->CallVoidMethod(thiz, callbackMethodId, dataObject); | |
} | |
#ifdef __cplusplus | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment