Sub Activity_Resume
SetupWebView
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
ExitApplication
End If
Return True
End Sub
Sub SetupWebView
WebView1.Initialize("WebView1")
Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
WebView1.JavaScriptEnabled = True
WebView1.ZoomEnabled=True
'add the B4A javascript interface to the WebView
WebViewExtras1.addJavascriptInterface(WebView1, "B4A")
'много е важно че без него браузъра не си знае енкодинга
WebSettings.setDefaultTextEncodingName(WebView1,"utf-8")
WebView1.LoadHtml(File.ReadString(File.DirAssets , "home.html"))
WebViewExtras1.addWebChromeClient(WebView1,"Event")
End Sub
'Вика се от HTML файла с javascript code
Sub ExitApp_Request(var1 As String)
'Log($"check_data(${var1})"$)
ExitApplication
End Sub
'Вика се от HTML файла с javascript code
Sub Book_Request(bookId As String)
Dim Javascript As String = $"B4A.CallSub('Process_HTML', true, document.documentElement.outerHTML)"$
WebViewExtras1.executeJavascript(WebView1, Javascript)
End Sub
private Sub Process_HTML(Html As String)
Log("trying to set the form")
Dim javascript As String = "var sid=document.getElementById('sid'); sid.value = '4321';" 'document.forms.myForm.submit();"
WebViewExtras1.executeJavascript(WebView1, javascript)
End Sub