android应用程序 - android模拟器虚拟SD卡 - swf文件未加载

时间:2012-01-10 12:04:13

标签: java android virtual android-sdcard

我想在我的Android应用程序中显示一个swf文件。

出于测试目的,使用Android模拟器。所以我为应用程序创建了一个虚拟SD卡来读取文件。在这个SD卡中我放了我的swf文件,我试图在我的代码中打开swf文件。

我没有在log cat上收到任何错误,但得到一个空白的屏幕。

我的代码在WebView上显示swf。

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.loadswf);
            String html =
                "<object width=\"550\" height=\"400\"><param name=\"movie\" value=\"file:///Demo_mobile.swf\">" +
                "<embed src=\"file:///Demo_mobile.swf\" width=\"550\" height=\"400\"> </embed> </object>";
                String mimeType = "text/html";
                String encoding = "utf-8";
            WebView wv=(WebView) findViewById(R.id.webview);
            wv.getSettings().setJavaScriptEnabled(true);
            wv.getSettings().setPluginsEnabled(true);
            wv.loadDataWithBaseURL("null", html, mimeType, encoding, "");
            wv.setWebViewClient(new HelloWebViewClient());

    }

专家请给我一个解决这个问题的方法。??

1 个答案:

答案 0 :(得分:0)

尝试以下代码,这可能对您有所帮助!

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);

然后您可以将数据加载到webview中,如此

    String html = "<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///sdcard/flash/2204355.swf\"> <embed src=\"file:///sdcard/flash/2204355.swf\" width=\"550\" height=\"400\"> </embed> </object>";
    String mimeType = "text/html";
    String encoding = "utf-8";

    mWebView.loadDataWithBaseURL("null", html, mimeType, encoding, "");

我只是在程序中制作了自定义html,并告诉它加载我存储在SD卡上flash文件夹中的flash文件。

相关问题