Skip to content

Instantly share code, notes, and snippets.



Created Sep 6, 2017
What would you like to do?
Example of calling android method from native code
void Log(std::string s){
JNIEnv *env;
g_JavaVM->GetEnv((void**)&env, JNI_VERSION_1_6);
jstring jstr1 = env->NewStringUTF(s.c_str());
jclass clazz = env->FindClass("diff/strazzere/secret/method");
// Later part is dalvik notation for parameters and return value, string param and void return value here
jmethodID mid = env->GetStaticMethodID(clazz, "methodname", "(Ljava/lang/String;)V");
jobject obj = env->CallStaticObjectMethod(clazz, mid, jstr1);
//In some initialization function with Environment variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment