33

I have a simple WebView to display a website with Flash (the Adobe Flash website) -- testing on a Xoom tablet running Android 3.0.1 with newly released Flash 10.2

After referring to every question on stackoverflow, I've set the following:

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.loadUrl("http://www.adobe.com/software/flash/about/");

Both Plugins and JavaScript are enabled for the WebView using getSettings(), yet Flash fails to show up. When I set setPluginState to ON_DEMAND, it shows the correct placeholder for Flash -- yet again, when I tap the item where Flash should be, the Flash disappears (as if the Flash video is failing to render) and only the audio (depending on the Flash content) can be heard.

I've also noticed that I can tap the missing Flash, do a long-hold tap, then tap the top left where the new Flash 'Fullscreen' button SHOULD be and it'll then show up correctly in Fullscreen mode. But when I fall back to the WebView, it again fails to show up and only plays the audio.

Any thoughts are appreciated! Please don't just refer me back to something posted months ago without some details on why I'm referring to a post months before the Android 3.0 release! Thanks again for any help. Great community!

Xezuka
  • 1,011
  • 1
  • 8
  • 10
  • I'd be interested to know the answer to this question myself. I created an app in android to render a web view into the background of a LiveWallpaper object and got the exact same behavior (minus the tapping + fullscreen, because I could only draw the canvas not attach the view). Anyway just thought I'd share that bit so you know it's not just you and thanks for posting this because it lets me know it's not just something I've done either! **EDIT** My app was on android 2.1 emu and 2.2 actual device htc desire got this behavior on both. –  Mar 22 '11 at 12:06

4 Answers4

35

So after a week and a half+ of searching high and low, trying different techniques, and just about near ready to throw my tablet out the window, I finally figured it out -- and I'm not too happy how EASY it was to fix; then again, I am!

Remember, this was directed toward the ISSUE of Flash video not loading into the WebView on my Xoom Android 3.0.1 tablet with PluginState ON. Read my question and then the answer. Enjoy!

Step 1: Simply add this to the tag under your Applications Manifest XML

android:hardwareAccelerated="true"

Step 2: Load up your app and enjoy your Flash enabled WebView!

Good luck!

Xezuka
  • 1,011
  • 1
  • 8
  • 10
  • I have the exact same symptoms - including doing the long push and tapping the upper left corner to get the video to show. But, the hardwareAccelerated fix doesn't work for me. Motorola Xyboard. – Dave Carlile Dec 28 '11 at 16:00
  • 1
    I was able to get this to work by moving hardwareAccelerated from the manifest tag to the activity tag. – Dave Carlile Dec 28 '11 at 16:25
  • It works on Android 4 (ICS), at least adding the property to the `activity` tag. – mdelolmo Jan 12 '12 at 11:26
  • works well for ICS. at least it worked for me nice and smooth. and i feel the same as u Xezuka when i found out how it is easy – denizt Jun 12 '12 at 12:31
  • @Xezuka,Some ics tablet webview load only half not full screen.help me.. some one – saravanan Mar 05 '13 at 05:52
  • Did't work for AVD Android 4.2.2 . Can somebody with working solution gives exact details: SDK version, AVD details, code sample. Tnx – Mitja Gustin May 22 '13 at 08:30
4
webView.setWebChromeClient(new WebChromeClient());

Don't know why but this helped me.

narek.gevorgyan
  • 4,165
  • 5
  • 32
  • 52
3

I have been through the same problem, I can only here audio and can see black screen into WebView. I am using Android 3.2 in Motorola Xoom.

After searching a lot for this solution, finally, I have been able to play video properly in my application.

Solution: I have created another android project with the single Activity containing WebView in it and set above tricks(i.e. android:hardwareAccelerated="true" etc.). Surprisingly, I was able to play the video perfectly into this project!

The strange thing is I was unable to play it with my application's project with the same source code and all. Anyhow it did work for me, don't know how!

prayagupa
  • 30,204
  • 14
  • 155
  • 192
Bharat Dodeja
  • 1,137
  • 16
  • 22
1

From the API doc here

In your Android manifest file, add the following attribute to the <application> tag to enable hardware acceleration for your entire application:

<application android:hardwareAccelerated="true" ...>

To enable or disable hardware acceleration at the activity level, you can use the android:hardwareAccelerated attribute for the <activity> element.

<application android:hardwareAccelerated="true">
    <activity ... />
    <activity android:hardwareAccelerated="false" />
</application>
Mithun Sreedharan
  • 49,883
  • 70
  • 181
  • 236