我正在開發一個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