2012-01-10 118 views
0

我想在我的android應用程序中顯示一個swf文件。android應用程序 - android模擬器虛擬sd卡 - swf文件不加載

出於測試目的,我正在使用android模擬器。所以我爲應用程序創建了一個虛擬sd卡來讀取這些文件。在這個sd卡中,我放入了swf文件,並試圖在我的代碼中打開swf文件。

在日誌貓沒有得到任何錯誤,但得到一個空白屏幕。

以下我的代碼在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()); 

    } 

請專家給我解決這個問題。

回答

0

請嘗試以下的代碼,這可能對您有幫助!

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裏面的程序,並告訴它加載,我已經保存在flash文件夾上一個Flash文件我SD卡。

+0

我的問題和你給的代碼有什麼區別? :) – 2012-01-10 12:33:33

+0

我在這裏申請了我的工作代碼,所以我可以在此找到路徑差異。 – 2012-01-10 12:34:56

+0

路徑..?在你的情況下,你把文件放在SD卡/閃存位置,在我的情況下,我把文件直接放在SD卡下。所以我需要像這樣只有...好嗎?有什麼方法可以在android模擬器上看到虛擬SD卡的內容。 – 2012-01-10 12:48:49