[英]android application - android emulator virtual sd card - swf file not loading
我想在我的android应用程序中显示swf文件。
为了进行测试,我使用了android emulator。 因此,我为应用程序创建了一个虚拟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());
}
专家请给我解决这个问题的方法。
尝试以下代码,这可能对您有帮助!
mWebView = (WebView) findViewById(R.id.webview);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
然后,您可以像这样将数据加载到Web视图中
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文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.