Android Question Load webpage in background

ttsolution

Member
Licensed User
Longtime User
Dear All,

Using webview, is there any way to load aspx web pages in background? My Activity have 04 webview, I want to load the webview1 first and the the webview2,webview3,webview4 in background.

Many thanks for any help.

Jonh,
 

ArminKH

Well-Known Member
put this code into a Service
B4X:
Public Sub AddWebView(WebView1 As WebView)
    WebView1.LoadUrl("http://www.google.com")
End Sub
then use this code in your activity
B4X:
    CallSubDelayed2(YourService,"AddWebView",WebView1)
    StartService(YourService)
    CancelScheduledService(YourService)
 
Upvote 0

ArminKH

Well-Known Member
The answer above is incorrect.

WebView always loads its content in the background. If for some reason you want to load the first page and only then start loading the second page then you need to handle the PageFinished event and then load the next page.
Erel my post is about a way to use webview in service when our app is closed
I know activity object can't assigned in service but this code works and this is my own solution for example when i want to reload a web page on background when my app is closed(Anti Idle user)
Is this wrong?
 
Last edited:
Upvote 0

ttsolution

Member
Licensed User
Longtime User
My case is : I have an aspx webpage show a sales report by Quarter. In my activity I have 04 webview stand for Quater1,Quater2, Quater3, Quater4 and I'm using
StdViewPager that allows user slide Quarter to Quarter. For optimized loading speed I wish to load the current Quarter first and the remain 03 quarters will be loaded in background.

I tried with arminkh solution & I works

Many thanks,

Jonh.
 
Upvote 0
Top