简体   繁体   中英

loading swf file on android emulator

Hi am newbie to android development. I had created one application where i need to load an swf file into the emulator. For that i put one swf file in the prjt-workspace/assets/test.swf and from the code i tried to load this swf into the WebView. Am getting the following error on logcat while trying to run this but getting a blank page:

01-10 15:26:00.271: D/WebCore(10262): Console: Not allowed to load local 
resource: file:///E:/android_new_workspace/FirstAndroidPrjt/assets/Demo_mobile.swf
line: 0 source: 

Following is the code portion i used:

public class WebViewExample extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loadswf);
        String html =
            "<object width=\"550\" height=\"400\"><param name=\"movie\" value=\"file:///E:/android_new_workspace/FirstAndroidPrjt/assets/Demo_mobile.swf\">" +
            "<embed src=\"file:///E:/android_new_workspace/FirstAndroidPrjt/assets/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());

         }
    }


public class HelloWebViewClient extends WebViewClient{

      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url) {
         view.loadUrl(url);
         return true;
      }

 }

Can anyone tell how we can solve this problem..?

Can we load swf by deirectly giving the url instead of filepath from system-directory.?

Experts please help...Thanks in advance..

@Tijo: you can specify with: webview.loadUrl("file:///android_asset/myown.swf");

or you can put something like this: <embed src=\\"file:///android_asset/BannerRotatorFX.swf\\" width=\\"550\\" height=\\"400\\"> </embed> </object>";

You cannot use filepath from your system directory. But you can put the swf file inside your assets folder in your android app

AFAIK, you cannot by default load swf in emulator since you cannot download the flashplayer in emulator AFAIK. But I think you can manually put the flashplayer library files inside your emulator for this to work although I haven't personally tried it. (I'm still looking where in the device the flashplayer libraries are residing so I can copy it).

I hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM