【问题标题】:Flash file does not display in webviewFlash 文件不显示在 webview 中
【发布时间】:2011-06-30 05:29:42
【问题描述】:

我尝试将 .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

【问题讨论】:

  • 我更新代码请看

标签: android flash android-webview


【解决方案1】:

请使用下面的代码

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

【讨论】:

  • 感谢您提供了一个好的代码,但我的问题是 Android 运行时 logcate.now 错误已删除,但当我运行项目时它无法运行。
  • 表示什么东西没有运行?
  • 在哪个android手机上测试呢?哪个版本?
  • 如果您发现此答案有帮助,请尝试 2​​.3 中的模拟器,然后点赞并纠正此答案,然后可能对其他人有帮助。
  • 当我在 avd 2.3.1 06-30 06:17:35.207 中运行项目时出现这种错误:ERROR/MetadataRetrieverClient(33): failed to extract an album art
猜你喜欢
  • 1970-01-01
  • 2011-07-19
  • 1970-01-01
  • 1970-01-01
  • 2012-07-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多