2012-01-10 113 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