Flash file does not display in webview
I try to load a .swf file from assets folder to a webview, but I am not able to display it.
Here is the code:
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);
Stri开发者_如何学Pythonng 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;
}
}
Manifest:
<?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>
Now I got a new error:
06-30 06:17:35.207: ERROR/MetadataRetrieverClient(33): failed to extract an album art
Please used below code
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, "");
OR
Reefer this link
精彩评论