Android Question WebViewExtras2: Getting access to the current WebResourceResponse

Martin Larsen

Active Member
Licensed User
Longtime User
In this thread warwound explains how to return a new WebResourceResponse using ShouldInterceptRequest. That works very well.

B4X:
Sub WebViewClient1_ShouldInterceptRequest(Url As String) As WebResourceResponse
    Log("WebViewClient1_ShouldInterceptRequest: "&Url)
    '    in this callback you have 2 options:
    '    return a WebResourceResponse which the WebView will use instead of requesting the webpage resource
    '    return Null and the WebView will continue with it's default action requesting the webpage response
   
    Select Url
        Case "http://www.b4x.com/android/forum/data/avatars/m/38/38207.jpg?1377605759"
            '    this should replace Rorry's avatar with a scooby doo image!
            Dim WebResourceResponse1 As WebResourceResponse
            WebResourceResponse1.Initialize("image/jpeg", Null, File.OpenInput(File.DirAssets, "scooby-doo-96x96.jpg"))
            Return WebResourceResponse1
        Case Else
            '    default action - let the webView retrieve the resource
            Return Null
    End Select
End Sub

But I need to have access to the default webpage resource in order to, among other things, to know the mime type of the request.

How do I do that?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…