AmirG AmirG - 5 months ago 9
Android Question

Webview is opening also the browser

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) {

});

Answer

SOLVED:

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

Comments