Search code examples
delphijava-native-interfacedelphi-10.2-tokyo

JObject to Integer and Integer to JObject


Does anyone know how to convert a JObject that was returned from android.hardware.camera2.CameraCharacteristics.get() to an Integer and also how to convert an Integer back to a JObject in Delphi.

Thank you
Sam


Solution

  • When requesting a Key whose type is a Java Integer, type-cast the returned JObject interface to JInteger, and then you can call its intValue() method.

    To assign a Delphi integer to a JObject, use the TJInteger.JavaClass.init() or TJInteger.JavaClass.valueOf() method, both of which take a Delphi Integer as input and return a JInteger interface, which you can then type-cast to JObject.