Android Question how can i reload records from json

Makumbi

Active Member
Licensed User
How can i reload this activity Layout without first closing it because i want to see the new message received thanks

B4X:
'Do not forget to load the layout file created with the visual designer. For example:
    If  IsConnectedToInternet=True Then
    replysms
    Activity.LoadLayout("simplechat")
    Activity.Title="Chat"
    
        activestudents
    Dim SQLQry As String = "DELETE FROM SMSlist"
    Starter.SQL1.ExecNonQuery(SQLQry)
        cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
    If cursor1.RowCount > 0 Then
            cursor1.Position =0
        Dim phone As String
        phone = cursor1.Getstring("Phone")
            Dim sx As String
        sx = cursor1.Getstring("Sex")
        'Next
    End If
    Dim CustID As String = phone' Customer ID
    Dim jt As HttpJob
    jt.Initialize("", Me)
        jt.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBGetTeachers.ashx?customerid=" & CustID)
 
    jt.GetRequest.Timeout = 10000 ' 10 seconds
    Wait For (jt) JobDone(jt As HttpJob)
    If jt.Success Then ' if job is success (http status code 200)
        Dim RetVal As String
        RetVal = jt.GetString
        If jt.GetString = "[]" Then
            'Msgbox("Please try Again ","SMIS")
            'Return
            
        Else
            
            Dim jpt As JSONParser
            jpt.Initialize(jt.GetString)
            Log(jpt) ' will pr
            Dim quotes As List = jpt.NextArray
            For Each quot As Map In quotes
                '    Log("Account: " & quot.Get("Account"))
                    Log("Name: " & quot.Get("Name"))
                    Log("Category: " & quot.Get("Category"))
                    Log("atk: " & quot.Get("atk"))
                    Log("Code: " & quot.Get("Code"))
                    Dim ltt As Long
                    DateTime.DateFormat = "dd/MM/yyyy" ' "1961-08-29"
                    Dim datestring As String = DateTime.Date(JsonDateToTick( quot.Get("Datesent")))
                    ltt = DateTime.DateParse(datestring)
                    DateTime.DateFormat = "dd/MM/yyyy"
                    Log(DateTime.Date(ltt))
            
  
                    Starter.SQL1.ExecNonQuery2("INSERT INTO SMSlist VALUES(?,?,?,?,?,?,?,?,?,?)", Array As Object(quot.Get("Account"), quot.Get("Name"), CustID,sx,quot.Get("sms"),DateTime.Date(ltt),quot.Get("atk"),quot.Get("Code"),quot.Get("Type"),1  ))
                    'Log(quot.Get("Account"))
                    'Log(quot.Get("Name"))
                    'Log(quot.Get(phone))
                    'Log(quot.Get(sx))
                    Log(RetVal) ' will print in log value returned from the server
                    
    
            '    End If
            Next
        
        End If
    
    'End If
    'InitSpinners
        'Msgbox("Records Processed Successfully. You Can Now Check ","SMIS")
    Else
        
            MsgboxAsync("Error Connecting to the Server Please Check Your Internet Connection","Server Error")
        Activity.LoadLayout("simplechat")
        Activity.Title="Chat"
        Return
        
        End If
        End If
End Sub
 
Top