When I run the code below I Get Networkonmainthreadexception error on this statement
resultString = Response.GetString("UTF8")
Anyone know what this means and why I am getting it?
It used to work Ok.
Many thanks.
resultString = Response.GetString("UTF8")
Anyone know what this means and why I am getting it?
It used to work Ok.
Many thanks.
B4X:
Sub GetWebPage
Dim req As HttpRequest 'Set up an http request connection
Dim PostUrl As String 'This will hold the url
PostUrl ="http://www.google.com"
req.InitializeGet(PostUrl) 'Initialize the http get request
ProgressDialogShow("Getting Messages...") 'Let The user know what is going on.
hc.Execute(req, 1)
End Sub
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int) 'We got connection and data !!
ProgressDialogHide 'Close the waiting message..
Dim resultString As String
Dim webstring As String
resultString = Response.GetString("UTF8") 'This holds the returned data
webstring = resultString.Replace("Google", "Edward") 'This will change google on the web to edward
textbox1.Text=resultString
WebView1.LoadHtml(webstring )
Response.Release
' Get prices.
' Dim sell1 As Int
' Dim sellprice As String
'
'' Find position of sell constant in HL webpage.
'
' sell1 = resultString.IndexOf("Sell:")
'
' sellprice = resultString.Substring2(sell1+105,sell1+111)
'
End Sub
Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int) 'No connection :-(
Log("Error connecting: " & Reason & " " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
ProgressDialogHide
Response.Release
End If
End Sub
Last edited: