Android Question Webview.onPageStarted?

dreamworld

Active Member
Licensed User
Longtime User
Hello, Erel.
My app needs Webview.onPageStarted and Webview.onScrollchanged, but the webview you wrote does not provide such events.
Can you provide any samples to write a library related to webview?
 

dreamworld

Active Member
Licensed User
Longtime User
I still can't figure out how to add events to a library without a sample.
Do you have any sample projects?
 
Upvote 0

dreamworld

Active Member
Licensed User
Longtime User
Could you give me a sample?
Or can you add onpagestarted and onScrollChanged events to the webview of B4A?
This is the simplest solution. It will be a hard work to build a new wrapper for the native WebView for me, but it is a quite simple work to add two events to B4A's WebView library for you.
And every developers of B4A can use those two events.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What do you want to to with OnPageStarted? I i call a Website then i AM in this moment in "OnStarted"... It makes NO(!) sense to have such an event!
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
You can get the onPageFinished event by using the latest version of my WebViewExtras library.
This latest version has not yet been properly uploaded to the forum, you can however download it from here: http://android.martinpearman.co.uk/b4a/temp/WebViewExtras2_20131012.zip.

Have a look at the DefaultWebViewClient object and you'll see the events that are currently supported.

This example shows the PageStarted event:

B4X:
Sub Process_Globals

End Sub

Sub Globals
   Dim WebView1 As WebView
   Dim WebViewExtras1 As WebViewExtras
End Sub

Sub Activity_Create(FirstTime As Boolean)
   WebView1.Initialize("")
   Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
  
   WebViewExtras1.Initialize(WebView1)
  
   Dim WebViewClient1 As DefaultWebViewClient
   WebViewClient1.Initialize("WebViewClient1")
  
   WebViewExtras1.SetWebViewClient(WebViewClient1)
  
   WebViewExtras1.LoadUrl("http://google.co.uk/")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub WebViewClient1_PageStarted(Url As String, FavIcon As Bitmap)
   Log("WebViewClient1_PageStarted Url="&Url)
End Sub

Now take a look at my FlingableWebView, thedesolatesoul has modified FlingableWebView adding support for the onScroll event.
Again this updated version is not uploaded to the forum, i'll send thedesolatesoul a message and ask him if you can have a copy of his updated FlingableWebView.

You can then use FlingableWebView instead of the default b4a WebView, initializing WebViewExtras with a FlingableWebView instead of a b4a WebView.

Martin.
 

Attachments

  • PageStarted.zip
    6 KB · Views: 191
Upvote 0

dreamworld

Active Member
Licensed User
Longtime User
You can get the onPageFinished event by using the latest version of my WebViewExtras library.
This latest version has not yet been properly uploaded to the forum, you can however download it from here: http://android.martinpearman.co.uk/b4a/temp/WebViewExtras2_20131012.zip.

Thanks. this is what I need.
As there is no onscrollchanged event in Webview, I use a timer to record the scroll position of webview.
When the webview goes back or forward, it can jump to those recorded scroll positions.
And I need to disable the timer before webview load a new page. therefore I need onpagestarted.
When clicking an link in a webpage, it is unable to do that without onpagestarted.

Warwound, can you add onscrollchanged to your library too.
I hope you upload your new library to B4A forum ASAP. Thanks.
 
Upvote 0
Top