Invoke() 공개 메소드

Called by the java vm whenever a method is invoked on the java proxy interface. You can override this to run special code on method invokation, or you can leave the implementation as is, and leave the default behavior which is to look for c# methods matching the signature of the java method.

public Invoke ( string methodName, AndroidJavaObject javaArgs ) : AndroidJavaObject
methodName string Name of the invoked java method.
javaArgs AndroidJavaObject Arguments passed from the java vm - all objects are represented by AndroidJavaObject, int for instance is represented by a java.lang.Integer object.
리턴 AndroidJavaObject
예제 #1
0
        public static IntPtr InvokeJavaProxyMethod(AndroidJavaProxy proxy, IntPtr jmethodName, IntPtr jargs)
        {
            int num = 0;

            if (jargs != IntPtr.Zero)
            {
                num = AndroidJNISafe.GetArrayLength(jargs);
            }
            AndroidJavaObject[] array = new AndroidJavaObject[num];
            for (int i = 0; i < num; i++)
            {
                IntPtr objectArrayElement = AndroidJNISafe.GetObjectArrayElement(jargs, i);
                array[i] = ((!(objectArrayElement != IntPtr.Zero)) ? null : new AndroidJavaObject(objectArrayElement));
            }
            IntPtr result;

            using (AndroidJavaObject androidJavaObject = proxy.Invoke(AndroidJNI.GetStringUTFChars(jmethodName), array))
            {
                if (androidJavaObject == null)
                {
                    result = IntPtr.Zero;
                }
                else
                {
                    result = AndroidJNI.NewLocalRef(androidJavaObject.GetRawObject());
                }
            }
            return(result);
        }
예제 #2
0
        public static IntPtr InvokeJavaProxyMethod(AndroidJavaProxy proxy, IntPtr jmethodName, IntPtr jargs)
        {
            int arrayLength = 0;

            if (jargs != IntPtr.Zero)
            {
                arrayLength = AndroidJNISafe.GetArrayLength(jargs);
            }
            AndroidJavaObject[] javaArgs = new AndroidJavaObject[arrayLength];
            for (int i = 0; i < arrayLength; i++)
            {
                IntPtr objectArrayElement = AndroidJNISafe.GetObjectArrayElement(jargs, i);
                javaArgs[i] = !(objectArrayElement != IntPtr.Zero) ? null : new AndroidJavaObject(objectArrayElement);
            }
            using (AndroidJavaObject obj2 = proxy.Invoke(AndroidJNI.GetStringUTFChars(jmethodName), javaArgs))
            {
                if (obj2 == null)
                {
                    return(IntPtr.Zero);
                }
                return(AndroidJNI.NewLocalRef(obj2.GetRawObject()));
            }
        }
예제 #3
0
        public static IntPtr InvokeJavaProxyMethod(AndroidJavaProxy proxy, IntPtr jmethodName, IntPtr jargs)
        {
            int length = 0;

            if (jargs != IntPtr.Zero)
            {
                length = AndroidJNISafe.GetArrayLength(jargs);
            }
            AndroidJavaObject[] javaArgs = new AndroidJavaObject[length];
            for (int index = 0; index < length; ++index)
            {
                IntPtr objectArrayElement = AndroidJNISafe.GetObjectArrayElement(jargs, index);
                javaArgs[index] = !(objectArrayElement != IntPtr.Zero) ? (AndroidJavaObject)null : new AndroidJavaObject(objectArrayElement);
            }
            using (AndroidJavaObject androidJavaObject = proxy.Invoke(AndroidJNI.GetStringUTFChars(jmethodName), javaArgs))
            {
                if (androidJavaObject == null)
                {
                    return(IntPtr.Zero);
                }
                return(AndroidJNI.NewLocalRef(androidJavaObject.GetRawObject()));
            }
        }