Setpluginsenabled Not Exist for Webview

Android webview setPluginsEnabled api

Starting in version 19 (4.4 - Kit Kat), Web Views have been updated to use chrome for their base. This can have different behavior to the old style webview. So you should test with a 4.4 device (or emulator...).

So anything below 19 uses the old webview and 19 and above uses the chrome based webview

See this link

webview setPluginEnabled(boolean) undefined

"This method was deprecated in API level 18. Plugins will not be supported in future, and should not be used."

see the question wich brings you the nswer : setPluginEnabled is undefined

setPluginState and setPluginsEnabled

A bit late - I'm sure you've figured it out by now - but the error is caused by the class PluginState not being available on Android versions < 2.2 (API 8). See the android docs on PluginState.

The reason why you can't catch this with try {} catch (Exception e) {} is because the NoClassDefFoundError is not an Exception - it's an Error. While Error and Exception are both children of Throwable they are not the same, hence you cannot catch an Error with an Exception and vice versa.

To solve this you can take either of the following approaches:

  1. Check which Android version the device is running, and only call PluginState when the device is running API-version >= 8.

  2. In your catch()-statement, catch NoClassDefFoundError instead of Exception.

Also, Eclipse will most likely show a Lint-warning mentioning the PluginState-class is only available on API 8+. You can hide/ignore this warning by adding @SuppressLint("NewApi") to the line above your method.

setPluginEnabled is undefined

According to http://developer.android.com/reference/android/webkit/WebSettings.html, there is no method setPluginsEnabled for WebSettings. Maybe it's an older method that has been removed in newer versions?

Additionally, the text next to setPluginState reads:

This method was deprecated in API level 18. Plugins will not be
supported in future, and should not be used.

You should probably follow that advice.

ChildBrowser.java syntax error

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.



Related Topics



Leave a reply



Submit