Android Question Camera2: how to implement "android.util.SizeF" class ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All

How to decode correctly the android.sensor.info.physicalSize: 5.2224x3.9168 that is in "android.util.SizeF" class ?

android.sensor.info.physicalSize: 5.2224x3.9168

B4X:
Private Sub PrintAllKeys (CameraMap As Object, title As String) 'ignore
    Log($"******  ${title} **********"$)
    Dim jo As JavaObject = CameraMap
    Dim keys As List = jo.RunMethod("getKeys", Null)
    For Each k As JavaObject In keys
        Dim value As Object = jo.RunMethod("get", Array(k))
        If value = Null Then Continue
        Dim typ As String = GetType(value)
        If typ = "[F" Then
            value = FloatsToList(value)
        Else If typ = "[I" Then
            value = IntsToList(value)
        Else If typ = "[Z" Then
            value = BoolsToList(value)
        Else If typ = "[B" Then
            value = BytesToList(value)
        Else if typ.StartsWith("[") Then
            value = ObjectsToList(value)
        Else if typ.EndsWith("SizeF") Then
            ??
        End If
        Log($"${k.RunMethod("getName", Null)}: ${value}"$)
        Dim name As String = k.RunMethod("getName", Null)
        If name = "android.sensor.info.physicalSize" Then
            Log(value)   'NOW IT'S EMPTY
        End If
    Next
End Sub

How correctly decode the value when name = "android.sensor.info.physicalSize" ?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 2

peacemaker

Expert
Licensed User
Longtime User
Thanks, Don, indeed !

B4X:
Type SizeF(width As Float, height As Float)
....

'Gets the sensor size.
Public Sub getSensorPhysicalSize As SizeF
    Dim jo As JavaObject = GetFromCameraCharacteristic("SENSOR_INFO_PHYSICAL_SIZE")
    Dim w As Float = jo.RunMethod("getWidth", Null)
    Dim h As Float = jo.RunMethod("getHeight", Null)
    Dim res As SizeF
    res.Initialize
    res.width = w
    res.height = h
    Return res
End Sub

Class v1.31 is attached
 

Attachments

  • CamEx2.bas
    18.5 KB · Views: 29
Upvote 0
Top