tom cat
tom cat

Reputation: 1

How to enable webview in androidstudio

I am trying to load an animated html file to draw arc and line. Please let me know how to enable javascript in android studio. Button click it should call the html file to draw arc or line. But it is simply viewing like text, Its not drawing. Please tell me how to call html canvas files in android studio.

I tried the following code to load my html file

   `WebView wv=(WebView) findViewById(R.id.mybrowser1);
    wv.getSettings().setPluginsEnabled(true);
    WebSettings webSettings = wv.getSettings();
    webSettings.setJavaScriptEnabled(true);`

But in android studio it is showing like cannot resolve method setPluginsEnabled(boolean).

Upvotes: 0

Views: 2242

Answers (2)

Amit Basliyal
Amit Basliyal

Reputation: 870

 WebView myWebView = (WebView) findViewById(R.id.webview1);
    myWebView.getSettings().setBuiltInZoomControls(false);
    myWebView.setVerticalScrollBarEnabled(false);
    myWebView.clearCache(true);
    myWebView.setFocusable(true);
    myWebView.setHorizontalScrollBarEnabled(false);
    myWebView.getSettings().setPluginState(PluginState.ON);
    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.getSettings().setAppCacheEnabled(true);
    myWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
    myWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    myWebView.getSettings().setAllowFileAccess(true);
    myWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    myWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

enter link description here

see this link

Upvotes: 0

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75798

webView.getSettings().setJavaScriptEnabled(true);

Tells the WebView to enable JavaScript execution. The default is false.

Upvotes: 1

Related Questions