我正在开发一个android 3.0平板电脑的应用程序,它应该在WebView中播放swf文件。 首先我试图从设备上打开swf文件,而不是通过互联网,没有运气。 WebView出现了,但在WebView内部,我所能看到的只是一个黑屏(在右边有一个3-4像素宽的白线)。 如果我将相同的URL加载到设备浏览器,则Flash文件播放良好。 我想我缺少WebView设置的东西,但经过几个小时的搜索和谷歌搜索,我仍然不知道什么。WebView不会在Android上播放swf文件
的Java代码:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setContentView(R.layout.presentation);
presentationWebView = (WebView) findViewById(R.id.presentation_webview);
presentationWebView.getSettings().setJavaScriptEnabled(true);
presentationWebView.getSettings().setPluginsEnabled(true);
presentationWebView.getSettings().setAllowFileAccess(true);
presentationWebView.loadUrl("http://my_domain/fileName.swf");
}
的presentation.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView
android:id = "@+id/presentation_webview"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"/>
</LinearLayout>
感谢您的任何答案非常mouch。 Ripityom
的可能重复的[加载的SWF到web视图(http://stackoverflow.com/questions/2994116/load-an-swf-into-a-webview)这似乎提供了解决方案。 – 2011-05-22 16:49:07