【问题标题】:android application - android emulator virtual sd card - swf file not loadingandroid 应用程序 - android 模拟器虚拟 sd 卡 - swf 文件未加载
【发布时间】:2012-01-10 12:04:12
【问题描述】:

我想在我的 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());

    }

请高手给我解决这个问题。??

【问题讨论】:

    标签: java android virtual android-sdcard


    【解决方案1】:

    试试下面的代码,可能对你有帮助!

        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,并告诉它加载我存储在我的 sdcard 上的 flash 文件夹中的 flash 文件。

    【讨论】:

    • 我的问题中的代码和你给出的代码有什么区别..?? :)
    • 我已经在这里应用了我的工作代码,所以我可以在这里找到路径的差异。
    • path ..?在您的情况下,您将文件放在位置 sdcard/flash 中,在我的情况下,我将文件直接放在 sdcard 下。??所以我只需要这样放..对吗?有什么办法可以在安卓模拟器上看到虚拟SD卡的内容吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    相关资源
    最近更新 更多