Answer the question
In order to leave comments, you need to log in
Why is javascript not working and images are not loading in WebView?
Good afternoon. I have a strange situation. I made a WebView application, but javascript does not work and some pictures are not loaded. And when you click on some page, after a reboot, everything loads and starts working.
package ru.djamali.vseza100;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.webview);
myWebView.setWebViewClient(new WebViewClient());
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.getSettings().setAppCacheEnabled(true);
myWebView.getSettings().setLoadsImagesAutomatically(true);
myWebView.loadUrl("http://www.mysite.ru");
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question