private void _AndroidJavaObject(string className, params object[] args) { this.DebugPrint("Creating AndroidJavaObject from " + className); bool flag = args == null; if (flag) { args = new object[1]; } IntPtr jobject = AndroidJNISafe.FindClass(className.Replace('.', '/')); this.m_jclass = new GlobalJavaObjectRef(jobject); jvalue[] array = AndroidJNIHelper.CreateJNIArgArray(args); try { IntPtr constructorID = AndroidJNIHelper.GetConstructorID(this.m_jclass, args); IntPtr intPtr = AndroidJNISafe.NewObject(this.m_jclass, constructorID, array); this.m_jobject = new GlobalJavaObjectRef(intPtr); AndroidJNISafe.DeleteLocalRef(intPtr); } finally { AndroidJNIHelper.DeleteJNIArgArray(args, array); } }
internal AndroidJavaObject(IntPtr jobject) : this() { if (jobject == IntPtr.Zero) { throw new Exception("JNI: Init'd AndroidJavaObject with null ptr!"); } IntPtr objectClass = AndroidJNISafe.GetObjectClass(jobject); this.m_jobject = new GlobalJavaObjectRef(jobject); this.m_jclass = new GlobalJavaObjectRef(objectClass); AndroidJNISafe.DeleteLocalRef(objectClass); }
protected virtual void Dispose(bool disposing) { bool flag = this.m_jobject != null; if (flag) { this.m_jobject.Dispose(); this.m_jobject = null; } bool flag2 = this.m_jclass != null; if (flag2) { this.m_jclass.Dispose(); this.m_jclass = null; } }
private void _AndroidJavaObject(string className, params object[] args) { this.DebugPrint("Creating AndroidJavaObject from " + className); if (args == null) { args = new object[1]; } using (AndroidJavaObject androidJavaObject = AndroidJavaObject.FindClass(className)) { this.m_jclass = new GlobalJavaObjectRef(androidJavaObject.GetRawObject()); jvalue[] array = AndroidJNIHelper.CreateJNIArgArray(args); try { IntPtr constructorID = AndroidJNIHelper.GetConstructorID(this.m_jclass, args); IntPtr intPtr = AndroidJNISafe.NewObject(this.m_jclass, constructorID, array); this.m_jobject = new GlobalJavaObjectRef(intPtr); AndroidJNISafe.DeleteLocalRef(intPtr); } finally { AndroidJNIHelper.DeleteJNIArgArray(args, array); } } }