0

Hello i used a webview to show a gif animation of a logo but in some phones with 4.0 - 4.2 SO if i touch the gif when coming from onresume it opens the browser in a blank page. and i cannot go into app till i close it. Why is this happening ?

 webViewSplash.clearCache(true);
    webViewSplash.reload();
    webViewSplash.setBackgroundColor(getColorResource(R.color.Transparent));
    webViewSplash.post(() -> {
        try {
            webViewSplash.loadDataWithBaseURL("file:///android_asset/", "<html style=\"margin: 0;\"> "
                            + "<body style=\"margin: 0;\"><img src=\"data:image/gif;base64,"
                            + Base64.encodeToString(Functions.readBytes(getResources()
                            .openRawResource(R.drawable.splash_animation)), Base64.DEFAULT)
                            + "\" style=\"width: 100%; height: 100%\" /> </body></html>",
                    "text/html", BuildConfig.DEFAULT_CHARSET, null);
        } catch (Exception ex) {

    });
AmirG
  • 595
  • 6
  • 18
  • 2
    Try `webViewSplash.setWebViewClient(new WebViewClient());` as per [here](http://stackoverflow.com/a/16354947/4428462), does that work ? – JonasCz May 06 '16 at 13:47
  • It actually worked ! do you know the reason behind this behavior? – AmirG May 06 '16 at 14:33
  • 1
    "When the user clicks a link from a web page in your WebView, the default behavior is for Android to launch an application that handles URLs. Usually, the default web browser opens and loads the destination URL. However, you can override this behavior for your WebView [...]" http://developer.android.com/guide/webapps/webview.html – Snild Dolkow May 06 '16 at 15:24
  • Thank you for that @SnildDolkow! – AmirG May 06 '16 at 15:44

1 Answers1

0

SOLVED:

Using myWebView.setWebViewClient(new WebViewClient()); worked. Thanksto @JonasCz and @SnildDolkow

AmirG
  • 595
  • 6
  • 18