Android Question java.util.HashMap to b4a list, map?

stanks

Active Member
Licensed User
Longtime User
How to?

With this part of code
B4X:
Dim s As String
s = XMLRPC1.objectCall3("authenticate", sesija.SubString2(8, sesija.Length), "", "")
Log(s)

i get
B4X:
{status=200, search_langs=[Ljava.lang.Object;@64bf6f70, search_restrict=false}

which is ok (status 200), but i want list from search_langs. if i put list instead of string i get err:
B4X:
java.lang.ClassCastException: java.util.HashMap cannot be cast to java.util.List

thanks
 

stanks

Active Member
Licensed User
Longtime User
tried and here is the err:

B4X:
java.lang.ClassCastException: java.util.HashMap cannot be cast to anywheresoftware.b4a.objects.collections.Map$MyMap
 
Upvote 0

stanks

Active Member
Licensed User
Longtime User
hm searchLangs - is a list of languages used but i am still getting

B4X:
[Ljava.lang.Object;@64bf9bd0

when i call

B4X:
Log(jo.RunMethod("get", Array("search_langs")))
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What is the complete code you are actually using?
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi all.
I have the same problem, I tried the code Erel, but the value returns null
If i write this code:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim XMLRPC1 As XMLRPC
    Dim XMLRPC2 As XMLRPC
 
    Private EditText1 As EditText
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
 
    Activity.LoadLayout("bus_roma_paline")
    If FirstTime Then
        XMLRPC1.Initialize("XMLRPC1")
        XMLRPC2.Initialize("XMLRPC2")
    End If
'Preleva Token
XMLRPC1.initXMLRPCClient("http://muovi.roma.it/ws/xml/autenticazione/1")
Dim vedi As String = XMLRPC1.objectCall2("autenticazione.Accedi","RwYtcwQz85DUpn6FPQCU7ImB2MBM8Dfl","")
Log(vedi)
ToastMessageShow(vedi, True)
EditText1.Text = "***Autentificazione***" & vedi & CRLF
 
 
'Preleva Tempo Bus sulla Palina
XMLRPC2.initXMLRPCClient("http://muovi.roma.it/ws/xml/paline/7")
Dim previsioni As Object  = XMLRPC2.objectCall3("paline.Previsioni",vedi,70101,"")
Log(previsioni) ' i wait that here return value
EditText1.Text = EditText1.Text & CRLF & "***Preleva Tempo***" & previsioni
 
 
 
End Sub
 
Sub Activity_Resume
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub

i have this result:

Screenshot_2015-06-10-14-02-04.png


all ok but in:

primi_per_palina = Ljava.lang.Object;@423bda78
arrivi = Ljava.lang.Object;@423bc6f0

another result is correct ( collacazione, nome, etc ).

Now if i use this code as suggestion Erel:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub
 
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim XMLRPC1 As XMLRPC
    Dim XMLRPC2 As XMLRPC
 
    Private EditText1 As EditText
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
 
    Activity.LoadLayout("bus_roma_paline")
    If FirstTime Then
        XMLRPC1.Initialize("XMLRPC1")
        XMLRPC2.Initialize("XMLRPC2")
    End If
'Preleva Token
XMLRPC1.initXMLRPCClient("http://muovi.roma.it/ws/xml/autenticazione/1")
Dim vedi As String = XMLRPC1.objectCall2("autenticazione.Accedi","RwYtcwQz85DUpn6FPQCU7ImB2MBM8Dfl","")
Log(vedi)
ToastMessageShow(vedi, True)
EditText1.Text = "***Autentificazione***" & vedi & CRLF
 
 
''Preleva Tempo Bus sulla Palina
'XMLRPC2.initXMLRPCClient("http://muovi.roma.it/ws/xml/paline/7")
'Dim previsioni As Object  = XMLRPC2.objectCall3("paline.Previsioni",vedi,70101,"")
'Log(previsioni) ' i wait that here return value
'EditText1.Text = EditText1.Text & CRLF & "***Preleva Tempo***" & previsioni
 
 
Dim jo As JavaObject = XMLRPC2.objectCall3("paline.Previsioni",vedi,70101,"")
'Log(jo.RunMethod("get", Array("primi_per_palina"))
Dim langs() As Object = jo.RunMethod("get", Array("primi_per_palina"))
For Each l As Object In langs
EditText1.Text = CRLF & l
Next
 
 
End Sub
 
Sub Activity_Resume
 
End Sub
 
Sub Activity_Pause (UserClosed As Boolean)
 
End Sub

i have this result:

Screenshot_2015-06-10-14-09-42.png


In attachment source.
Any idea ?
Thank you all
Marco
 

Attachments

  • BusRoma.zip
    9 KB · Views: 173
Upvote 0
Top