Android Question How to obtain the current webpage title of the Webview?

aironium

Member
For context, I am currently developing an app for my capstone project (I call it Zyngil, a debt manager for micro-stores/variety stores in the Philippines). The sign up page is a B4xpage object with a webview... er view. Honestly I don't know if I am asking the correct question, but yeah, I want to get the page title of the currently loaded site in the webview view.

Also, I had to use a webview instead of the usual designer-based inputs is for sending queries in a remote mysql database (and gonna admit, I have no idea how to make a b4xpage scrollable, sorry)

Basically, my plan is that upon registration, the app is supposed to read something from the website and trigger a subroutine (basically redirect user to splash b4xpage object).

Below here is just the signup page in development.
 

Attachments

  • Screenshot_20221112-124428.jpg
    Screenshot_20221112-124428.jpg
    266.8 KB · Views: 145

drgottjr

Expert
Licensed User
Longtime User
i don't know about all the rest, but if you wait until the webview has loaded, you
can get its title (assuming it has one), as well as the url. you can then make your
decisions as to what action to follow

B4X:
sub webview_PageFinished(url as string)
    Dim jo As JavaObject = webview
    Dim title As String = jo.runMethod("getTitle",Null)
    Log("your title: " & title)

'    Dim Url As String = jo.runMethod("getUrl",Null)
'    you can also retrieve the url manually, but you
'    get it for free in this sub

    Log("your url: " & Url)
End Sub
 
Upvote 0

aironium

Member
i don't know about all the rest, but if you wait until the webview has loaded, you
can get its title (assuming it has one), as well as the url. you can then make your
decisions as to what action to follow

B4X:
sub webview_PageFinished(url as string)
    Dim jo As JavaObject = webview
    Dim title As String = jo.runMethod("getTitle",Null)
    Log("your title: " & title)

'    Dim Url As String = jo.runMethod("getUrl",Null)
'    you can also retrieve the url manually, but you
'    get it for free in this sub

    Log("your url: " & Url)
End Sub
I will give this a shot, thanks!
 
Upvote 0
Top