Android Question From a string in Edittext to byte array AStreams

FreeWolF

Active Member
Licensed User
Longtime User
Hello, how can I put a converted string in a Astream byte array?

B4X:
Dim dati() As Byte
  
    dati = Array As Byte(0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA)
  
    AStreams.Write(dati)

This example works fine.

But I want something like this:

B4X:
Dim dati() As Byte
Dim testo as string

testo = "0x01, 0x10, 0x01, 0x0A, 0x00, 0x01, 0x02, 0x01, 0xFF, 0xF7, 0xEA"
  
    dati = Array As Byte(testo)
  
    AStreams.Write(dati)

How can I do it?

I have tried with the second example I have wrote, but I receive: "An Error has occured in sub: java.lang. NumberFormatException: Invalid double: " " Continue?

Thanks in advance!!!
 
Top