【发布时间】:2011-05-21 12:31:41
【问题描述】:
我正在为 android 3.0 平板电脑开发一个应用程序,它应该在 WebView 中播放 swf 文件。 首先,我尝试从设备打开 swf 文件,而不是通过互联网打开,但没有成功。 WebView 出现了,但在 WebView 内部,我只能看到一个黑屏(右侧有 3-4 px 宽的白线)。 如果我将相同的 URL 加载到设备浏览器,则 Flash 文件可以正常播放。 我想我在 WebView 设置上遗漏了一些东西,但经过几个小时的搜索和谷歌搜索后,我仍然不知道是什么。
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>
非常感谢您的任何回答。 呸呸呸
【问题讨论】:
-
Load an SWF into a WebView 的可能副本,这似乎提供了解决方案。
标签: android flash android-webview