New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
alexcq
Old
#1  
Junior Member - OP
Thanks Meter 0
Posts: 5
Join Date: Aug 2009
Default Flash in a WebView

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?
 
nrkabul
Old
#2  
Member
Thanks Meter 8
Posts: 31
Join Date: Jul 2009
Quote:
Originally Posted by alexcq View Post
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
 
alexcq
Old
#3  
Junior Member - OP
Thanks Meter 0
Posts: 5
Join Date: 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.
 
nrkabul
Old
#4  
Member
Thanks Meter 8
Posts: 31
Join Date: Jul 2009
Quote:
Originally Posted by alexcq View Post
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
 
cchiro
Old
#5  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: Aug 2010
Default 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.
 
pharrisee
Old
#6  
Member
Thanks Meter 0
Posts: 92
Join Date: Apr 2010
Have you tried asking this question at http://anddev.org ?
 
royiby
Old
#7  
Junior Member
Thanks Meter 0
Posts: 7
Join Date: Aug 2010
Default 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?
 
profete162
Old
#8  
Recognized Developer
Thanks Meter 128
Posts: 717
Join Date: Jul 2009

 
DONATE TO ME
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...

Tags
android, flash, hero, websettings, webview

XDA PORTAL POSTS

What’s Possible with CASUAL & How to Make Your Own CASUAL – XDA Developer TV

XDA Elite Recognized Developer AdamOutler is known … more

Pearl Chen to Talk NFC Development at XDA:DevCon 2013

From HTML to LEDs or Android to Arduino, Hardware Hacking is a pastime of many people … more

Avoid Framework Bootloops on Xperias Running Jelly Bean

If you’re a Sony device owner running a stock Android Jelly Bean firmware and … more

Forum Added for the Samsung Galaxy Mega

What do you do when the Galaxy Note line is simply not big enough? You get theSamsung Galaxy Mega. … more