質問

In ChildBrowser.java (2.0.0) line: 356 Cordava: 2.9.0

is syntax error:

The method setPluginsEnabled(boolean) is undefined for the type WebSetting

                // WebView
       webview = new WebView(ctx.getActivity());
       webview.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
       webview.setWebChromeClient(new WebChromeClient());
       WebViewClient client = new ChildBrowserClient(edittext);
       webview.setWebViewClient(client);
       WebSettings settings = webview.getSettings();
       settings.setJavaScriptEnabled(true);
       settings.setJavaScriptCanOpenWindowsAutomatically(true);
       settings.setBuiltInZoomControls(true);


       settings.setPluginsEnabled(true);


       settings.setDomStorageEnabled(true);
       webview.loadUrl(url);
       webview.setId(6);
       webview.getSettings().setLoadWithOverviewMode(true);
       webview.getSettings().setUseWideViewPort(true);
       webview.requestFocus();
       webview.requestFocusFromTouch();

And I don't know how to remove it.

Thank you for help.

TB

役に立ちましたか?

解決

The method you're looking for has been deprecated and removed from the public API with the introduction of Android 4.3 (API level 18):

/**
 * Sets whether the WebView should enable plugins. The default is false.
 *
 * @param flag true if plugins should be enabled
 * @deprecated This method has been deprecated in favor of
 *             {@link #setPluginState}
 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
 */
@Deprecated
public synchronized void setPluginsEnabled(boolean flag) {
    throw new MustOverrideException();
}

Link to source code.

As pointed out in the Javadoc above, starting API level 18, you can use the following method in stead, and pass in PluginState.ON.

setPluginState(WebSettings.PluginState state)

Do note that this method has also been deprecated saying that "Plugins will not be supported in future, and should not be used.". Link.

Here's the actual API 18 diff report for WebSettings, giving a handy overview of all changes to the class.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top