using System; using JNI; namespace MyNamespace { class MyClass { public int GetIntegerValue(IntPtr javaInstance) { JNIEnv env = JNIEnv.GetEnv(); int integerValue = env.CallNonvirtualIntMethod(javaInstance, env.FindClass("com/example/package/TestClass"), env.GetMethodID(env.GetObjectClass(javaInstance), "getIntegerValue", "()I")); return integerValue; } } }
using System; using Android.Views; using JNI; namespace MyNamespace { class MyClass { public int GetViewHeight(IntPtr viewInstance) { JNIEnv env = JNIEnv.GetEnv(); int height = env.CallNonvirtualIntMethod(viewInstance, env.FindClass("android/view/View"), env.GetMethodID(env.GetObjectClass(viewInstance), "getHeight", "()I")); return height; } } }This example will create an instance of the "JNIEnv" environment, and then call the "CallNonvirtualIntMethod" method to call the "getHeight" method of an instance of the "android.view.View" class. The "CallNonvirtualIntMethod" method is part of the JNI package library, which is included in the Java Development Kit (JDK).