On Apr 16, 2012, at 7:04 PM, Paul Johnson wrote: > JNIEnv.Get*ID requires the type of the variable to be IntPtr, but then > requires IntPtr kls, string name, string signature for the parameters. > Unfortunately, the documentation on the API area gives the "documentation to > be added" line for kls which isn't much help.
As per the API Design document [0], you can (normally) use the similarly named JNI function documentation: http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html In particular, for e.g. GetMethodID(), you want a Class reference, the name of the method, and the method signature: http://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html#wp16656 The Binding Android Types documentation may also be helpful: http://docs.xamarin.com/android/advanced_topics/Binding_Android_Types#_Instance_Methods http://docs.xamarin.com/android/advanced_topics/Binding_Android_Types#JNI_Type_Signatures > private bool prepareModal() > { using (var MessageQueue_Class = Java.Lang.Class.FromType(typeof(Android.OS.MessageQueue))) using (var Message_Class = Java.Lang.Class.FromType(typeof(Android.OS.Message))) { mMsgQueueNextMethod = JNIEnv.GetMethodID(MessageQueue_Class.Handle, "next", "()Landroid/os/Message;"); mMsgTargetField = JNIEnv.GetFieldID(Message_Class.Handle, "target", "Landroid/os/Handler;"); return true; } > private void doModal() > { > mQuitModal = false; > > // get message queue associated with main UI thread > MessageQueue queue = Looper.MyQueue(); > while (!mQuitModal) > { > // call queue.next(), might block > Message msg = null; > try > { > // invoke not available > msg = (Message)mMsgQueueNextMethod.invoke(queue, new > Object[] { }); IntPtr _msg = JNIEnv.CallObjectMethod(queue.Handle, mMsgQueueNextMethod); if (_msg == IntPtr.Zero) return; using (msg = Java.Lang.Object.GetObject<Android.OS.Message>(_msg, JniHandleOwnership.TransferLocalRef)) { IntPtr _target = JNIEnv.GetObjectField(msg.Handle, mMsgTargetField); if (_target == IntPtr.Zero) { mQuitModal = true; return; } using (var target = Java.Lang.Object.GetObject<Android.OS.Handler>(_target, JniHandleOwnership.TransferLocalRef)) { target.DispatchMessage(msg); msg.Recycle(); } } - Jon [0] http://docs.xamarin.com/android/advanced_topics/api_design#Java_Native_Interface_Support _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid