如何在Android中播放.swf文件? [英] How to play .swf files in Android?

查看:300
本文介绍了如何在Android中播放.swf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了Adobe Flash Player apk,通过将其从资产复制到SD卡并使用Intent进行安装。即使在那之后,webView也无法加载.swf文件。我应该使用Adobe Flash Builder来开发Android应用程序吗?我的主要要求是从服务器播放.swf文件!

这是我的代码。

  @Override 
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_flash);

installFlashPlayer();


// Fake Url
// String url =http://www.test.com/test.swf;
//
// webView =(WebView)findViewById(R.id.webView);
// webView.getSettings()。setPluginState(WebSettings.PluginState.ON);
// webView.setWebViewClient(新的WebViewClient());
//
// webView.getSettings()。setUseWideViewPort(true);
// webView.getSettings()。setLoadWithOverviewMode(true);
// webView.loadUrl(url);


$ b void installFlashPlayer(){
AssetManager assetManager = FlashActivity.this.getAssets();

InputStream in = null;
OutputStream out = null;

尝试{
in = assetManager.open(flp.apk);
out = new FileOutputStream(Environment.getExternalStorageDirectory()+/flp.apk);

byte [] buffer = new byte [1024];

int read; $(读取= in.read(缓冲区))!= -1){

out.write(buffer,0,read);

}

in.close();
in = null;

out.flush();
out.close();
out = null;

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory()+/flp.apk)),
application / vnd.android.package-archive) ;

startActivity(intent);
$ b} catch(Exception e){}
}


解决方案

您可以使用GeckoView of Firefox


用于播放swf文件。



还需要设置 plugin.state.flash = true; 在GeckoView ..



不好主意是你的apk会增加20-25 MB,如果你选择使用GeckoView(如果我没有记错的话),因为GeckoView适用于jni ...

I installed Adobe Flash Player apk by copying it from assets to SD card and installing it using Intent. Even after that, webView is not able to load the .swf file.

Should i use Adobe Flash builder instead to develop the Android application. My primary requirement is to play .swf files from the server!

Here is my code.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_flash);

        installFlashPlayer();


//Fake Url
//        String url = "http://www.test.com/test.swf";
//
//        webView = (WebView) findViewById(R.id.webView);
//        webView.getSettings().setPluginState(WebSettings.PluginState.ON);
//        webView.setWebViewClient(new WebViewClient());
//
//        webView.getSettings().setUseWideViewPort(true);
//        webView.getSettings().setLoadWithOverviewMode(true);
//        webView.loadUrl(url);

    }

    void installFlashPlayer(){
        AssetManager assetManager = FlashActivity.this.getAssets();

        InputStream in = null;
        OutputStream out = null;

        try {
            in = assetManager.open("flp.apk");
            out = new FileOutputStream(Environment.getExternalStorageDirectory()  + "/flp.apk");

            byte[] buffer = new byte[1024];

            int read;
            while((read = in.read(buffer)) != -1) {

                out.write(buffer, 0, read);

            }

            in.close();
            in = null;

            out.flush();
            out.close();
            out = null;

            Intent intent = new Intent(Intent.ACTION_VIEW);

            intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/flp.apk")),
                    "application/vnd.android.package-archive");

            startActivity(intent);

        } catch(Exception e) { }
    }

解决方案

You can use "GeckoView of Firefox" I used this in my project.

Useful for playing swf files.

Also you need to set plugin.state.flash = true; in GeckoView..

The bad idea is your apk will increase 20-25 mb if you choose to use GeckoView (if i didnot remember wrong) , because GeckoView works with jni...

这篇关于如何在Android中播放.swf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆