I found my problem. Apparently in Android 5.0 shouldInterceptRequest will
not be run if their is a problem with the url being loaded. I was
using loadDataWithBaseURL("foobar://, data, encoding, null) to load first
page. Since foobar:// is not a known prefix to a url or file the request
was just being dropped. I changed foobar to http:// or file:/// and
everything started working as it did on Android 4.1. I guess a check was
introduced on 5.0 that was not being done before.
On Friday, May 20, 2016 at 5:57:50 PM UTC-6, Carlos Farrington wrote:
>
> Hi
>
> I am developing an App that intercepts the request and process them and
> then updates send the WebResourcesResponse. The code works with no issues
> on 4.2 but when I try it in 5.0 the function shouldInterceptRequest never
> sees the request. I know that there was an update on the library and I
> have made the modifications but I do not see any requests being processed.
> As you can see I have added a toast message to tell me if we enter the
> shouldInterceptRequest function but I never see the message. The requests
> that are being processes are simple gets of a html page with frames. On 4.2
> works with no problem but on 5.0 it does not work. Any ideas?
>
> Thank you,
>
> fc8282
>
>
>
> private class WebViewClientImpl extends WebViewClient
> {
> @Override
> public boolean shouldOverrideUrlLoading(WebView view, String url)
> {
> return false;
> }
>
> @Override
> public void onPageFinished(WebView view, String url)
> {
>
> }
>
> @SuppressWarnings("deprecation") // From API 21 we should use another
> overload
> @Override
> public WebResourceResponse shouldInterceptRequest ( final WebView
> view, String msg)
> {
> return processRequest ( view, msg );
> }
>
> //@TargetApi(Build.VERSION_CODES.LOLLIPOP)
> @TargetApi(android.os.Build.VERSION_CODES.LOLLIPOP)
> @Override
> public WebResourceResponse shouldInterceptRequest( WebView view,
> WebResourceRequest request)
> {
> Toast.makeText(getBaseContext(), "We are in the
> shouldInterceptRequest 5.0: ",
> Toast.LENGTH_LONG).show();
>
>
> String msg = request.getUrl().toString();
>
> return shouldInterceptRequest(view, request.getUrl().toString());
>
> // Have also tried just simply doing the return.
> //return processRequest ( view, msg );
> }
>
>
> public WebResourceResponse processRequest ( final WebView view,
> String msg )
>
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/6799a4db-324e-42e5-a1b7-58537cf114cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.