Flash文件不会显示在webview中

时间:2011-06-30 05:29:42

标签: android flash android-webview

我尝试将.swf文件从assets文件夹加载到webview,但我无法显示它。

以下是代码:

package com.androidpeople.view;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class WebViewExample extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);



    String html =
        "<object width=\"550\" height=\"400\"> <param name=\"movie\"   value=\"file:///android_asset/co.swf\"> <embed src=\"file:///android_asset/co.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());



}
}
package com.androidpeople.view;

import android.webkit.WebView;
import android.webkit.WebViewClient;

public class HelloWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    view.loadUrl(url);
    return true;
}

}

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.androidpeople.view"
  android:versionCode="1"
  android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".WebViewExample"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
<uses-sdk android:minSdkVersion="5" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest> 

现在我收到了一个新错误:

06-30 06:17:35.207: ERROR/MetadataRetrieverClient(33): failed to extract an album art

1 个答案:

答案 0 :(得分:4)

请使用以下代码

String html =
"<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///android_asset/co.swf\"> <embed src=\"file:///android_asset/co.swf\" width=\"550\" height=\"400\"> </embed> </object>";
String mimeType = "text/html";
String encoding = "utf-8";
wv.loadDataWithBaseURL("null", html, mimeType, encoding, "");

冷藏箱this link