Hi.
There's no easy way to access the page title - the WebView itself has no methods of any use.
You can use my
JSInterface library to send some javascript to the web page though.
That javascript can get the document.title property you want and send it back to a B4A Sub:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim PageTitle As String
Dim WebInterface As JSInterface
Dim WebView1 As WebView
End Sub
Sub Activity_Create(FirstTime As Boolean)
WebView1.Initialize("WebView1")
WebInterface.addJSInterface(WebView1, "B4A")
Activity.AddView(WebView1, 0, 0, -1, -1)
WebView1.LoadUrl("http://www.b4x.com/android/help/jsinterface.html")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub WebView1_PageFinished (Url As String)
Log("PageFinished: "&Url)
WebInterface.execJS(WebView1, "B4A.CallSub('SavePageTitle', document.title)")
Log("Page title requested")
End Sub
Sub SavePageTitle(title As String)
PageTitle=title
Log("The page title has been saved: "&title)
End Sub
That works in an asynchronous way - the B4A code waits for the page to load then asks the page to send it's title back to B4A.
You'd not be able to simply write code:
Dim Title As String
Title=WebView1.DocumentTitle
So watch that the page title has been received in your B4A code before you try to use it.
Martin.