'How to call a void method from using android ndk
I'm trying to call a void method from my C++ code. I already have jclass, and JNIEnv*. I have no problem calling static methods, because I can simply use the jclass instance that I have. However, Using env->CallVoidMethod(), I read that I need to pass an object instead. The method is a part of my MainActivity class, so do I need to create an instance of the MainActivity class as seen in the debugging screenshot attached below? If so, how do I get the constructor Method ID for MainActivity?
-------------UPDATE code shown below-------------
jclass clazz = env->FindClass((MenuUtilities::getPathFromPackage() + "/MainActivity").c_str());
jmethodID constructor = env->GetMethodID(clazz, "MainActivity", "()V"); //👈This returns null..
jobject newObj = env->NewObject(clazz, constructor);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

