V
V
Valentin Khoroshilov2019-06-06 00:26:35
Java
Valentin Khoroshilov, 2019-06-06 00:26:35

How to add javascript support to webview android studio?

package com.example.webnure;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MainActivity extends AppCompatActivity {

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webView = new WebView(this);
        setContentView(webView);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("https://nure.ua/");
     

    }
    
}

How to add javascript support to webview?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentin Khoroshilov, 2019-06-06
@horoshi10v

Found

webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true);
        webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); 
        webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false);
        webSettings.setSupportZoom(true); webSettings.setDefaultTextEncodingName("utf-8");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question