Android Question Byte array as Object for RunMethod


Active Member
Licensed User
Longtime User
The Bluetooth setPin method is defined as

public boolean setPin (byte[] pin)

RunMethod for "setPin" requires an Object so the parameter cannot be a byte array
B4A version 4.30
Parsing code. 0.30
Compiling code. Error
Error compiling program.
Error description: Cannot cast type: {Type=Byte,Rank=1, RemoteObject=True} to: {Type=Object,Rank=1, RemoteObject=True}
Occurred on line: 617
If job.RunMethod("setPin", Array As Byte(pinBytes)) Then
Word: )

Is this the correct way to turn an array of bytes into an object?

' Note    Dim job As JavaObject - then set to bluetooth device
    Dim pinBytes() As  Byte = Array As Byte(0x31,0x32,0x33,0x34)

    If job.RunMethod("setPin", Array As Object(pinBytes)) Then
        Log("set pin returned true")
        Log("set pin returned false ")
    End If

This code does run without an exception but always returns false!