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); }
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)); } }