[英]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.