I detected the next issue and maybe one of you can help me.
I created a WebView and loaded a page that use WebRTC technology in order to establish video-conference between two devices.
Everything was OK up this point. Now I want to change my network connection (for instance from 3G to Wi-Fi), and the problems appears. The media streaming is not working. This streaming is over a P2P connection between two devices.
To avoid it, my first approach was destroying the WebView and regenerating it again, but didn't work.
I believe that some process that WebView starts keeps in memory, because if I delete in a hard mode the process depending on the activity, it works, but it is not elegant in a release version.
How will be the best solution to create again the WebView, or at least to destroy it?
Here it is my poor solution. I created the WebView programmatically, without included in activity XML view. I read about memory leaks and timers on WebView, but it didn't work. I also used the ApplicationContext to create the WebView.
public void destroyWebView() {
Log.d(TAG, "Destroy webView");
if(webView != null) {
webView.removeAllViews();
webView.clearHistory();
webView.clearCache(true);
webView.loadUrl("about:blank");
webView = null;
parentWebView.removeAllViews();
}
}
@Override
protected void onDestroy() {
Log.d(TAG, "*** ON DESTROY");
if (webView != null) {
destroyWebView();
}
android.os.Process.killProcess(android.os.Process.myPid());
super.onDestroy();
}