Android 如何在 Webview 中启用 Flash 插件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2943947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:59:34  来源:igfitidea点击:

How to Enable Flash Plugin in Webview?

androidflashwebview

提问by Pavanadroid

How to Enable Flash Plugin in Webview Browser?

如何在 Webview 浏览器中启用 Flash 插件?

回答by MrBuBBLs

You just need to enable the plugins for the webview, like this :

您只需要为 webview 启用插件,如下所示:

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.

我认为您还需要安装 Flash,就像在 Android 2.2 及更高版本中一样。希望这可以帮助。

This method is now deprecated, I'll try to explain this more in detail. See here

此方法现已弃用,我将尝试更详细地解释这一点。看这里

回答by Nick Felker

I believe that you can

我相信你可以

WebSettings webSettings = myWebView.getSettings();
webSettings.setPluginState(PluginState.ON);

will work.

将工作。

回答by Halil SAFAK

setPluginsEnabled() and setPluginsEnabled() are deprecated.

setPluginsEnabled() 和 setPluginsEnabled() 已弃用。

To make Flash Player work in a WebView you need to enable hardware acceleration in your AdroidManifest.xml.

要使 Flash Player 在 WebView 中工作,您需要在 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

您还可以通过使用为您的 WebView 单独启用它

mWebView.setLayerType(View.LAYER_TYPE_HARDWARE, null);

回答by Parimal Debbarma

webView.getSettings().setPluginState(PluginState.ON); 

is deprecated now, instead use this:

现在已弃用,请改用:

webView.getSettings().setMediaPlaybackRequiresUserGesture(true);

回答by Narendrakumar

try to use this lines of code

尝试使用这行代码

webView.getSettings().setPluginState(PluginState.ON);   

instead of using

而不是使用

 webView.getSettings().setPluginsEnabled(true);

Its work fine...

它的工作正常...

回答by jon

  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();