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 开发者_如何学JAVAup 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!
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!
webView.setWebChromeClient(new WebChromeClient());
Don't know why but this helped me.
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!
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>
精彩评论