Post Reply

Flash in a WebView

OP alexcq

27th August 2009, 12:39 PM   |  #1  
OP Junior Member
Thanks Meter: 0
 
5 posts
Join Date:Joined: Aug 2009
Ooops I posted this to the main Hero forum yesterday by mistake - it is more properly and Android developer post specific to the Hero. . . .

I've been trying to run Flash in a Webview on my Hero.

Flash runs in the standard Browser okay, but I get the 'missing plugin' icon when trying to view anthing with Flash in the WebView.

I'm not sure if it has been disabled, or I just haven't found the right settings. I'm using the standard,

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

Then I'm also calling (through reflection) the 'setFlashPlayerEnabled' method described by cyanogen
http://forum.xda-developers.com/showthread.php?t=521221

//Set Flash Player Enabled
Boolean[] input={new Boolean(true)};
try{
Class cl=Class.forName("android.webkit.WebSettings");
Class[] par=new Class[1];
par[0]=Boolean.TYPE;
Method mthd=cl.getMethod("setFlashPlayerEnabled",par);
mthd.invoke(mWebView.getSettings(),input);
mWebView.loadUrl("file:///android_asset/index.html");
}catch(Exception e){}

But still no Flash in the WebView.

Is there anything else that needs to be called?

How about
setPluginsPath("")

. . . . what path should that call on the Hero?
27th August 2009, 07:47 PM   |  #2  
Member
Thanks Meter: 9
 
31 posts
Join Date:Joined: Jul 2009
Quote:
Originally Posted by alexcq

Code:
}catch(Exception e){}

On general Java principles, I'd put some code in this exception handler to see if something is thrown when you get the method or do the invoke...

Otherwise, no ideas
31st August 2009, 09:49 PM   |  #3  
OP Junior Member
Thanks Meter: 0
 
5 posts
Join Date:Joined: Aug 2009
Thanks for that - generally I'm using

mWebView.loadUrl("http://www.google.com/"+e.toString());

while debugging on the device to have any errors sent to the URL bar. A bit nasty, but it gets me the info.
1st September 2009, 06:43 PM   |  #4  
Member
Thanks Meter: 9
 
31 posts
Join Date:Joined: Jul 2009
Quote:
Originally Posted by alexcq

Thanks for that - generally I'm using

mWebView.loadUrl("http://www.google.com/"+e.toString());

while debugging on the device to have any errors sent to the URL bar. A bit nasty, but it gets me the info.

nice one
19th August 2010, 09:33 AM   |  #5  
Junior Member
Thanks Meter: 0
 
1 posts
Join Date:Joined: Aug 2010
Android 2.2 Flash in a WebView
Hi,
I just tried loading a swf in a WebView and it seems to be working. I needed to enable setPluginsEnabled(true); which I saw in your post. Thanks.
19th August 2010, 09:38 AM   |  #6  
Member
Thanks Meter: 0
 
92 posts
Join Date:Joined: Apr 2010
Have you tried asking this question at http://anddev.org ?
3rd October 2010, 02:31 PM   |  #7  
Junior Member
Thanks Meter: 0
 
7 posts
Join Date:Joined: Aug 2010
let me guess - Android version is 2.1 or lower
I came to that conclusion after i noticed that on my N1 running 2.2 this works flawlessly but on my Evo running 2.1 it shows gibberish.

am i correct?
23rd February 2011, 07:41 PM   |  #8  
Recognized Developer
Thanks Meter: 167
 
729 posts
Join Date:Joined: Jul 2009
Donate to Me
More
Hello all.

After trying using flash in my application, I have been very disapointed.

Once the webview is loaded, all my activity blink.

You can find a more accurate description, and the source code of the issue here: http://stackoverflow.com/questions/5...iew-with-flash

and the demo apk here: http://cl.ly/3g0s1p030j243y0p3m2F


Thank a lot for any help, I cannot sleep till I fix this issue...

Post Reply Subscribe to Thread

Tags
android, flash, hero, websettings, webview
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes