0

I am working with WebView , it is working fine with all versions and devices except Sony Xperia Z 4.3, API level 18, the url I am loading in WebView consists of some texts and images.

Code I used

java

overViewDetail = (WebView) findViewById(R.id.detail_tv);


WebSettings settings = overViewDetail.getSettings();

settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setJavaScriptEnabled(true);
settings.setDefaultTextEncodingName("utf-8");

Xml

 <WebView
     android:id="@+id/detail_tv"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_margin="10dp"
     android:text="@string/overview_details"
     android:textColor="@color/colorfont"
     tools:ignore="WebViewLayout" />

PS : I have searched on many solutions but they didn't worked for me

references

Webview content not loading all devices

Android webview javascript seems not working on Sony Xperia

Android stock browser on Xperia Z does not render html correctly

android dev : is any specific multithreading coding with Sony Xperia?

Oğuzhan Döngül
  • 7,856
  • 4
  • 38
  • 52
Atif Afridi
  • 61
  • 2
  • 12
  • 1
    On the second reference link it mentions to set: `webView.setWebChromeClient(new WebChromeClient());` after `webView.getSettings().setJavaScriptEnabled(true);` Have you done this and if yes why it is not posted on your question's code? – pleft Oct 30 '17 at 08:11
  • 1
    yes i have done that but not tested yet – Atif Afridi Oct 30 '17 at 11:05
  • 1
    what is purpose of .setWebChromeClient(new WebChromeClient()); – Atif Afridi Oct 30 '17 at 11:06

1 Answers1

0

Try this :

 WebView x = (WebView)findViewById(R.id.x);
 x.getSettings().setJavaScriptEnabled(true);
 x.setWebViewClient(new WebViewClient());
 x.loadUrl("");

And don't forget this in Manifest :

 <uses-permission android:name="android.permission.INTERNET" />