Sub Process_Globals
End Sub
Sub Globals
Dim WebViewExtras1 As WebViewExtras
Dim WebView1 As WebView
Private Button1 As Button
Private Button2 As Button
Private EditText1 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main.bal")
'WebView1.SetLayout(0,0,100%x,80%y)
' add the JavascriptInterface to WebView1
WebViewExtras1.addJavascriptInterface(WebView1, "B4A")
WebViewExtras1.addWebChromeClient(WebView1,"Chrome")
EditText1.text="1111111 2222222 3333333"
WebView1.LoadUrl("file:///android_asset/test2.html")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
........
End Sub
Sub Button2_Click
..........
End Sub
Sub WebView1_PageFinished (Url As String)
Dim Javascript As String
Javascript="B4A.CallSub('ProcessHTML', false, document.documentElement.outerHTML)"
Log("PageFinished: "&Javascript)
'If Url="url_of_the_login_page" Then
Dim Javascript As String
Dim MyWebViewExtras As WebViewExtras ' you could make this a global variable if you use it elsewhere in your code
Javascript ="B4A.CallSub('ProcessHTML', true, document.getElementById('field1').getAttribute('value'))"
MyWebViewExtras.executeJavascript(WebView1, Javascript)
Log("Javascript")
' alternatively you could execute the javascript without requiring WebViewExtras by using the javascript protocol:
' WebView1.LoadUrl("javascript:"&Javascript.ToString)
Log("PageFinished: "&Javascript)
End Sub
Sub ProcessHTML(Html As String)
' This is the Sub that we'll get the web page to send it's HTML content to
' Log may truncate a large page so you'll not see all of the HTML in the log but the 'html' String should still contain all of the web page HTML
Log("ProcessHTML: "&Html)
End Sub