コード例 #1
0
        public static object ParseJavaBoxedValue(AndroidJavaObject boxedValueAjo)
        {
            if (boxedValueAjo == null || boxedValueAjo.IsJavaNull())
            {
                return(null);
            }

            var className = boxedValueAjo.GetClassSimpleName();

            switch (className)
            {
            case "Boolean":
                return(boxedValueAjo.CallBool("booleanValue"));

            case "Float":
                return(boxedValueAjo.CallFloat("floatValue"));

            case "Integer":
                return(boxedValueAjo.CallInt("intValue"));

            case "Long":
                return(boxedValueAjo.CallLong("longValue"));

            case "String":
                return(boxedValueAjo.CallStr("toString"));
            }
            return(boxedValueAjo);
        }
コード例 #2
0
        public static void CheckIfClassIsCorrect(AndroidJavaObject ajo, string expectedSimpleClassName)
        {
            var actualSimpleClassName = ajo.GetClassSimpleName();

            if (actualSimpleClassName != expectedSimpleClassName)
            {
                throw new InvalidOperationException(string.Format(
                                                        "This AndroidJavaObject is not {0}, it is {1}!", expectedSimpleClassName, actualSimpleClassName));
            }
        }