[Android]How to load swf file in Android (API 23)

余生长醉 提交于 2020-01-17 13:57:29

问题


I want to load swf file in Android , but it seems that Android don't support swf.
I google it,and most of developers suggest to use webview:

WebSettings settings = webview.getSettings();
settings.setPluginsEnabled(true);
webView.getSettings().setPluginState(WebSettings.PluginState.ON);
webView.loadurl("....swf");

but setPluginsEnabled was removed and setPluginState is deprecated in Api level 23.


回答1:


"but it seems that Android don't support swf"

Yes and as you've been told... Adobe stopped allowing Flash Player on mobile browsers. They instead recommend that you open FlashPlayer content within an app only because.. drumroll... Adobe have their own tool to create Android apps and only their tool allows opening SWF within a mobile app.

The catch is that any SWF loaded into an app cant just run its own code (could be un-safe code from a bad-minded person). So the next best things is to use Flash's own StageWebView to open a html page that has a flash embed and everything runs perfectly like on a computer browser (only this time via that StageWebView part of your Flash-made Android app).

So to answer..

I want to load swf file in Android

simply download the latest Flash CC (dev toolkit) and re-create your app through ActionScript-3 code instead of Java code. They are both C-like languages (though I feel AS3 is closer to C# than Java in terms of API names etc but as you can see where Java/Android has "WebView" well AS3 has "StageWebView" so it might not be that hard to switch for this app (if important enough to justify learning a new OOP language)




回答2:


You can use https://wiki.mozilla.org/Mobile/GeckoView

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 did not remember wrong) , because GeckoView works with jni...



来源:https://stackoverflow.com/questions/33781068/androidhow-to-load-swf-file-in-android-api-23

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