How to play .swf files in Android?

你。 提交于 2019-12-12 03:36:46

问题


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) { }
    }

回答1:


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...



来源:https://stackoverflow.com/questions/39124351/how-to-play-swf-files-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!