Does anybody know how to get the Current Page Title from a WebView. This was accomplished in b4a by using the 'WebViewsExtender' Library. Here is the b4a code used from the OAuth example which is my ultimate goal.
B4X:
Sub wv_PageFinished (Url As String)
If Url.StartsWith("https://accounts.google.com/o/oauth2/approval") Then
Dim wv As WebView
wv = Sender
Dim w As WebViewXtender
Dim result As String
result = w.getTitle(wv)
wv.RemoveView 'remove the WebView
If result.StartsWith("Success code") Then
AuthorizationCode = result.SubString("Success code=".Length)
GetAccessToken
Else
Log("Error: " & result)
ToastMessageShow(result, True)
End If
End If
End Sub
Sub getWebPageTitle(wv As WebView) As String
Dim result As String = ""
Try
' Get the webview
Dim joWV As JavaObject = wv
' Get the webengine from the webview using method getEngine
Dim joWE As JavaObject = joWV.RunMethod("getEngine", Null)
' Obtain the page title from the webengine javaobject using method getTitle
result = joWE.RunMethod("getTitle", Null)
Catch
result = LastException.Message
End Try
Return result
End Sub
Example usage:
B4X:
Private wvwMain As WebView
MainForm.Title = getWebPageTitle(wvwMain)
Here a B4J HOWTO example project using JavaObject Methods with a WebView.