Android Question How to pull and refresh My webview App ?

bulana2004

Member
WebView App:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private WebView1 As WebView
    Private WebViewExtra As WebViewExtras
    Private Chrome As DefaultWebChromeClient
    Private LocationPermisison As Boolean
End Sub


Public Sub Initialize
    '    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")   
    
    WebView1.Height = Root.Height
    WebView1.Width = Root.Width
    Chrome.Initialize("chrome")
    WebViewExtra.Initialize(WebView1)
    WebViewExtra.SetWebChromeClient(Chrome)
    WebView1.LoadUrl("https://akmeemanaps.lk/APP")
    Dim rp As RuntimePermissions
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION) Or rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) Then
        LocationPermisison = True
    End If
End Sub

Private Sub Chrome_GeoLocationPermissionsRequest As Int
    Log("Chrome_GeoLocationPermissionsRequest")
    Return IIf(LocationPermisison, Chrome.GEOLOCATION_PERMISSION_ALLOW_AND_REMEMBER, Chrome.GEOLOCATION_PERMISSION_DISALLOW_AND_REMEMBER)
End Sub

Private Sub B4XPage_closeRequest As ResumableSub
    WebView1.Back
    Return False
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

bulana2004

Member
B4XMainPage - 8: Variable 'AHSwipeToRefresh1' was not initialized. (warning #11)


B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private WebView1 As WebView
    Private WebViewExtra As WebViewExtras
    Private Chrome As DefaultWebChromeClient
    Private LocationPermisison As Boolean
    Private AHSwipeToRefresh1 As AHSwipeToRefresh
End Sub


Public Sub Initialize
    '    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")   
    
    WebView1.Height = Root.Height
    WebView1.Width = Root.Width
    Chrome.Initialize("chrome")
    WebViewExtra.Initialize(WebView1)
    WebViewExtra.SetWebChromeClient(Chrome)
    Dim pnl As B4XView = xui.CreatePanel("")
    WebView1.RemoveView
    AHSwipeToRefresh1.AddView(pnl)
    pnl.AddView(WebView1, 0, 0, pnl.Width, pnl.Height)
    WebView1.LoadUrl("https://www.google.com")
    Dim rp As RuntimePermissions
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If rp.Check(rp.PERMISSION_ACCESS_FINE_LOCATION) Or rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) Then
        LocationPermisison = True
    End If
End Sub

Private Sub Chrome_GeoLocationPermissionsRequest As Int
    Log("Chrome_GeoLocationPermissionsRequest")
    Return IIf(LocationPermisison, Chrome.GEOLOCATION_PERMISSION_ALLOW_AND_REMEMBER, Chrome.GEOLOCATION_PERMISSION_DISALLOW_AND_REMEMBER)
End Sub

Private Sub B4XPage_closeRequest As ResumableSub
    WebView1.Back
    Return False
End Sub

Private Sub AHSwipeToRefresh1_Refresh
    Log("refreshing")
    WebView1.LoadUrl("http://www.google.com")
    Wait For WebView1_PageFinished (Url As String)
    AHSwipeToRefresh1.Refreshing = False
End Sub
 
Upvote 0
Top