Sub WebView1_PageFinished (Url As String)
Dim Javascript As String
Javascript="B4A.CallSub('ProcessHTML', false, document.documentElement.outerHTML)"
WebViewExtras1.executeJavascript(MyWebV, Javascript)
End Sub
Sub ProcessHTML(Html As String)
ProcessHtmlData(Html)
Label1.Text="Any Thing"
End Sub
i get error when try to write any thing to label (i try to add label using code or using Activity.LoadLayout)
B4X:
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
from what I was able to find out after getting the same error .. B4A.CallSub runs on a non GUI thread , whereas all code involving GUI views etc .. must be run on the Main thread.
This was solved by downloading the threading library Here ...
then ...
B4X:
Sub Globals
Private Thread1 As Thread 'maybe should be Process_Globals ?
End Sub
Sub ProcessHTML(Html AsString)
ProcessHtmlData(Html)
Thread1.Initialise("Thread1")
Thread1.RunOnGuiThread("Process_Views" , Null)
End Sub
Sub Process_Views
Label1.Text="Any Thing"
End Sub