问题
How to Enable Flash Plugin in Webview Browser?
回答1:
You just need to enable the plugins for the webview, like this :
WebView mWebView = (WebView) findViewById(R.id.WebView01);
mWebView.getSettings().setPluginsEnabled(true);
I think you also need Flash to be installed, like in Android 2.2 and above. Hope this helps.
This method is now deprecated, I'll try to explain this more in detail. See here
回答2:
I believe that you can
WebSettings webSettings = myWebView.getSettings();
webSettings.setPluginState(PluginState.ON);
will work.
回答3:
setPluginsEnabled() and setPluginsEnabled() are deprecated.
To make Flash Player work in a WebView you need to enable hardware acceleration in your AdroidManifest.xml.
<application
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/appicon"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
You can also individually enable it for your WebView by using
mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
回答4:
try to use this lines of code
webView.getSettings().setPluginState(PluginState.ON);
instead of using
webView.getSettings().setPluginsEnabled(true);
Its work fine...
回答5:
webView.getSettings().setPluginState(PluginState.ON);
is deprecated now, instead use this:
webView.getSettings().setMediaPlaybackRequiresUserGesture(true);
回答6:
package com.ageofwar2;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.webkit.WebView;
public class MainActivity extends Activity {
/** com.ageofwar2 */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
String url ="file:///android_asset/Flash.swf"; //AgeOfWar2.swf
WebView mWebView=(WebView) findViewById(R.id.web_engine);
webView.getSettings().setPluginState(PluginState.ON);
webview.loadUrl();
来源:https://stackoverflow.com/questions/2943947/how-to-enable-flash-plugin-in-webview