// Get the Java class object IntPtr javaClass = JNIEnv.FindClass("com.example.MyClass"); // Get the Java method object that returns an integer IntPtr javaMethod = JNIEnv.GetMethodID(javaClass, "myMethod", "()I"); // Call the Java method and retrieve the integer result int result = JNIEnv.CallIntMethod(javaClass, javaMethod);
// Get the Java object reference IntPtr javaObject = // ... // Get the Java method object that returns an integer IntPtr javaMethod = JNIEnv.GetMethodID(JNIEnv.GetObjectClass(javaObject), "myMethod", "()I"); // Call the Java method on the object and retrieve the integer result int result = JNIEnv.CallIntMethod(javaObject, javaMethod);In these examples, the package library is not specified. The package library is determined by the class name passed to the JNIEnv.FindClass function.