Android Question label2.text give [Ljava.lang.String;@216abcd8 answer

Izmirov.Yaminovich

Member
Licensed User
Longtime User
Good day to all of you, i want to ask about this outcome of this coding
B4X:
Sub Astreams_NewData (buffer() As Byte)
   
    
    msg = conv.HexFromBytes(buffer)
    msg2 = Regex.Split("FE1C",msg)
   

    label1.Text = msg
    label2.Text = msg2
End Sub

i took this code from usb serial and i modify it, but why the label2.text is giving "[Ljava.lang.String;@216abcd8 " answer.And give a warning " Object converted to string. This is probably a programming mistake"

And also i try to change it to this new version of code

B4X:
Sub Astreams_NewData (buffer() As Byte)
   
    
    msg = conv.HexFromBytes(buffer)
    msg2 = Regex.Split("FE1C",msg)
    Dim msg3 As String
    Dim List1 As List
List1.Initialize
For Each row() As String In msg2
List1.Add(row(0))
Next

    label1.Text = msg
    label2.Text = List1
End Sub

but it gave me this error

For Each row() As String In msg2
javac 1.6.0_26
src\b4a\example1\main.java:350: incompatible types
found : java.lang.String
required: anywheresoftware.b4a.BA.IterableList
final anywheresoftware.b4a.BA.IterableList group59 = mostCurrent._msg2;

I have try all the related things that I found in the forum but doesnt have any outcome
 

Izmirov.Yaminovich

Member
Licensed User
Longtime User
Thanks for replying Erel. I have declared msg2 like this
B4X:
Dim msg2() as string

and i have modify the code like this.

B4X:
Sub Astreams_NewData (buffer() As Byte)
   
     Dim notsame As String
     notsame  = "same from above"
    msg = conv.HexFromBytes(buffer)
    msg2 = Regex.Split("FE1C",conv.HexFromBytes(buffer))
   
    Dim List1 As List
List1.Initialize
For Each row As String In msg2

If row.CompareTo(msg)= 0 Then
label2.text = notsame
Else
label2.Text = row
End If
Next
End Sub

It seem to work just like i want. Thanks Erel

Cheeer
 
Upvote 0
Top