• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Play a local swf-file (flash) with webview?

xtreme

Lurker
I guess webview is the best solution to play a local swf-file (flash). I just get cryptic character in the emulator with this html code in webview.

HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Flash</title>
</head>

<body>
<object width="550" height="400">
<param name="movie" value="Flashfile.swf">
<embed src="Flashfile.swf" width="550" height="400">
</embed>
</object>

</body>
</html>

How can i play a local swf-file when the user click on some kind of link, java or html?
 
If you want to play it in a webview you would first need to create your webview with these settings

Code:
		mWebView = (WebView) findViewById(R.id.webview);
		mWebView.getSettings().setJavaScriptEnabled(true);
		mWebView.getSettings().setPluginsEnabled(true);

You can then load data into the webview like so
Code:
		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, "");

I simply made custom html inside the program and told it to load a flash file that I had stored in the flash folder on my sdcard.

keep in mind that in the custom html you have to escape the " with a back slash like this \" so that it wont end the string. You also have to have it all on one line unless you want to append strings together like so

Code:
String myString = "something" + "something else"
 
Yes, thank a lot, but by a local file, I meant a file from the asset folder.

Of, course, I can copy it to the SdCard, but wouldn't it be better and cleaner for the user to use the asset folder, something like:


Code:
value=\":///[B]asset folder[/B]/2204355.swf\"

Thank a lot.
 
if you want to use a file in the assets folder you would just have to change this part of the html string from this
Code:
<param name=\"movie\" value=\"file:///sdcard/flash/2204355.swf\"> <embed src=\"file:///sdcard/flash/2204355.swf\" width=\"550\" height=\"400\">

and change the value and src parts to this

Code:
<param name=\"movie\" value=\"file:///android_asset/2204355.swf\"> <embed src=\"file:///android_asset/2204355.swf\" width=\"550\" height=\"400\">

All you have to do is put the file in the assets folder. And make sure when you add it to your project that you copy the file in and not just link to it
 
Just amazing!
One of my client is asking for a tablet-sized presentation for his marketting team.
They wanted to make an interactive presentation of their products.

Making animations with Android was really hurting and painful!
Flash just saved my life.

Thank a lot, man!
 
Hi
I try this code but the swf didn't display into the webview.

Code:
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        objectview= (WebView)this.findViewById(R.id.webkit);
        //ex
 

Attachments

  • im.JPG
    im.JPG
    4.4 KB · Views: 270
public void onCreate(Bundle savedInstanceState) {
WebView mWebView;
super.onCreate(savedInstanceState);

setContentView(R.layout.
main);
mWebView =(WebView) findViewById(R.id.​
webview);
mWebView.getSettings().setJavaScriptEnabled(
true);
mWebView.getSettings().setPluginsEnabled(
true);

String html =​
"<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///android_asset/changing_tyres.swf\"> <embed src=\"file:///android_asset/changing_tyres.swf\" width=\"550\" height=\"400\"> </embed> </object>";
String mimeType =
"text/html";
String encoding =
"utf-8";
mWebView.loadDataWithBaseURL(
"null", html, mimeType, encoding, "");

}


I have used the above code to display my swf file changing_tyres.swf. But the screen is blank when i run in the emulator. I have just followed the code that was written above. Only thing that I changed was the swf file. Could you please tell me what could have gone wrong or why the screen is blank.

 
Note: I'm using an Asus Transformer and trying to launch a simple webview app in 3.1 (API lvl 12).

I am having the same issue.

I've seen the code above all over the place (StackOverflow and the like), and it's all pretty much identical, but none of it works.

When I run it, I get a black screen. If I change the file name, I get "Webpage not available," so I'm pretty sure that's correct.

I think it has something to do with the plugin. If I use the standard browser, I can hit flash games just fine. However, I navigated to a Facebook game with the webview app that I made, and the game doesn't appear. There's a white space allotted for it, and oddly, the music is playing, but the game doesn't appear.
 
I have a game in a swf file, is there a possibility to make an application for android in Eclipse where user can in their own mobile invoke and play with this .swf ? (maybe from a webView?)

can I do it using FLEX? but I don't have a concrete idea

(sorry is the theme is repetitive here, i couldn't find something that can help me)

hope you guys can help me :confused:
 
Back
Top Bottom