2

I'm developing a browser for Android.

Is it possible to create a Checkbox Preference to enable and disable Flash plugin (webview.setPluginsEnabled) in the Preferences?

<CheckBoxPreference
android:title="Enable/Disable Flash"
android:key="chkbox_flash"

Here I need the code to set WebView.getSettings().setPluginsEnabled(boolean) 
to true or to false />
Caio Cunha
  • 23,326
  • 6
  • 78
  • 74

1 Answers1

0

I don't develop to Android, but seems you should add a listener to your CheckBoxPreference like this checkboxpreference-onclick (docs)

Then you set the state of the plugin off. Heres the doc. Basically, you have to do:

WebView webview = new WebView(this);
webview.getSettings().setPluginState(PluginState.OFF);

You shouldn't use setPluginsEnabled, as it is deprecated. Note, though, it'll disable any plugins, not only Flash.

Community
  • 1
  • 1
Caio Cunha
  • 23,326
  • 6
  • 78
  • 74
  • And how would the listener look like? Sorry, I'm only a beginner. – user1590059 Aug 10 '12 at 12:54
  • Something like this http://stackoverflow.com/questions/6496450/android-checkbox-preference and this http://stackoverflow.com/questions/531427/how-do-i-display-the-current-value-of-an-android-preference-in-the-preference-su – Caio Cunha Aug 10 '12 at 13:12