Reputation: 124
Hi,i try to load an webview and i dont know why some HTML make app crash with the logs above.i have to say that the html is really simple
<style type="text/css">
body {
font-size: 14;
text-align: justify;
max-width: 100%;
word-break: break-all;
word-break: break-word
}
img {
display: inline;
height: auto;
max-width: 100%;
}
iframe {
display: inline;
height: auto;
max-width: 100%;
}
</style>
<html>
<body>
<p align="justify" line-height="1.5">
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">[ TxxxxY] </font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxx, </font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxxy. </font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">* xxxxxx9. </font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">*xxxxxxố 5 </font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3">xxxxxxxxxxxxxxxxx!</font></span></p>
<p class="p1"><span class="s1" style="caret-color: rgb(0, 0, 0); -webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961); -webkit-text-size-adjust: 100%; background-color: rgba(255, 255, 255, 0);"><font color="#000000" face="sans-serif" size="3"><br></font></span></p>
</p>
</body>
</html>
and the load weview method
if (Build.VERSION.SDK_INT >= 19) {
webView.setLayerType(webView.isHardwareAccelerated() ? View.LAYER_TYPE_HARDWARE :
View.LAYER_TYPE_NONE, null);
} else {
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
webView.loadDataWithBaseURL("", html, "text/html; charset=utf-8", "utf-8", "");
I think it look like something about JNI.so please any suggest about this
Upvotes: 0
Views: 212
Reputation: 420
Not sure of the JNI error, but I tried your html with this approach and it worked fine.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_webview)
web.settings.javaScriptEnabled = true
web.loadUrl("file:///android_asset/myhtml.html");
}
May be try running in a different emulator or device. It might be emulator specific issue
Upvotes: 1