在我的应用运行一段时间后,将swf加载到webview中会出现问题。我想flash插件已经崩溃,但我不知道如何捕获此错误以尝试重新创建webview。发生错误时,webview不会加载swf内容。
我使用NanoHTTPD作为网络服务器。
WebSettings webSettings = getSettings();
webSettings.setPluginState(PluginState.ON);
webSettings.setJavaScriptEnabled(true);
setTranslationX(x);
setTranslationY(y);
String uuid = UUID.randomUUID().toString();
String vars = "rssfeed=" + rssSource + "&apppath=" + RSS_PATH + "&imgpath=" + IMG_PATH;
String filename = "template/" + template;
StringBuffer sBuf = new StringBuffer();
sBuf.append("<html>\n");
sBuf.append("<body style=\"margin:0;width:100%;overflow:hidden;background:"+ bgcolor + ";\">\n");
sBuf.append("<embed id=\"plugin\" name=\"plugin\" width=\"100%\" height=\"100%\" \n"
+ "allowScriptAccess=\"sameDomain\" scale=\"exactfit\" wmode=\"transparent\" src=\""
+ filename
+ "\" \n"
+ "type=\"application/x-shockwave-flash\" FlashVars=\""
+ vars
+ "\">\n");
sBuf.append("</body>\n");
sBuf.append("</html>");
String html = sBuf.toString();
Log.d("HTML", html);
addJavascriptInterface(new AreaInterface(Config.getContext()),"AreaInterface");
setWebViewClient(new AreaViewClient());
loadDataWithBaseURL("http://localhost:8081", html, MIME_TYPE, ENCODING, null);
java.lang.NullPointerException
at android.content.res.Resources.openRawResourceFd(Resources.java:982)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:604)
at com.adobe.flashplayer.RawConfigResources.GetAssetFileDescriptor(RawConfigResources.java:37
at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
at android.webkit.JWebCoreJavaBridge.sharedTimerFired(Native Method)
at android.webkit.JWebCoreJavaBridge.fireSharedTimer(JWebCoreJavaBridge.java:92)
at android.webkit.JWebCoreJavaBridge.handleMessage(JWebCoreJavaBridge.java:108)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:818)
at java.lang.Thread.run(Thread.java:856)