My application uses a WebView to display flash video contents.
Everything seems to go smoothly
until you try to play full screen on Android ICS devices.
It works fine on devices with lower version.
On ICS devices it throws a NullPointerException.
Here is my code:
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.setVerticalScrollbarOverlay(true);
webView.setWebViewClient(new WebViewClient() {
private ProgressDialog pd;
@Override
public void onPageStarted(WebView view, String url,
Bitmap favicon) {
pd = new ProgressDialog(TrainingDetailActivity.this);
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setMessage("Loading");
pd.show();
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
this.dismissDialog();
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
return false;
}
private void dismissDialog() {
if (pd != null) {
pd.dismiss();
pd = null;
}
}
});
webView.loadDataWithBaseURL(baseUrl, htmlstr, "text/html", "utf-8", null);
After some digging, I found out that in ICS the android.webkit.PluginFullScreenHolder show() method gets called and throws
an NullExceptionPointer. The problem lays there, not on my code.
I tried some work around but none of them works.
- Work around : I added this line:
webView.setWebChromeClient(new WebChromeClient() );
With this work around the NullPointerException does not occur, but the video plays with no sound, and won't switch to
Full screen mode.
I looked around stackoverflow for solutions, the closest which seems to solve my problem is this answer:
https://stackoverflow.com/a/9921073/1503155
But unfortunately the answerer didn't explain what is the variable base
in his code snippet and I am still stuck.
My question is, is there a way to work around this bug. Is yes, How?
Thanks in advance.