ShouldoverrideUrlLoading not called on samsung galaxy and HTC devices

524 views Asked by At

I am doing something like this:

LoadDataWithBaseURL("file:///android_asset/adhese/",fileContent, "text/html", "UTF-8", null); 

My Webviewclient class:

public class DataWebViewClient : WebViewClient
{
    public delegate void PageLoaded();
    public event PageLoaded PageLoadedEvent;
    public AndroidAdController controller;

    public override bool ShouldOverrideUrlLoading (WebView view, string url)
    {
        if(url.Contains ("addsResponseLoaded"))
        {
            view.EvaluateJavascript ("window.giveMeMyResponse();", controller.JSResultObj);
            //view.StopLoading ();
            return false;
        }
        return true;
    }

    public override void OnPageStarted (WebView view, string url, Android.Graphics.Bitmap favicon)
    {
        if (!url.Contains ("addsResponseLoaded"))
            base.OnPageStarted (view, url, favicon);
        else
            view.StopLoading ();
    }

}

The javascript functions:

 function giveMeMyResponse(){
        // send the ads object and the response object to the native app as json
        return "[{\"myAds\":"+JSON.stringify(ads)+",\"myResponse\":"+JSON.stringify(myResponse)+"}]";
    }
    ads.response.then(function (response) {
        // send a signal to the native app the adds have succesfully loaded by changing the url to addsResponseLoaded
        myAds = ads;
        myResponse = response;
       this.document.location.href = "addsResponseLoaded";
    });

On some devices like the oneplus one, onpagestarted is called and after that shouldoverrideurlloading is called.

But on other devices like htc or samsung galaxy, the shouldoverrideurlloading method is never called. How should i handle this?

0

There are 0 answers