Hello,
I have the following problem with a WebView Control. I have the following code:
public class MyWebView extends Activity {
private WebView webview;
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mywebview);
...
webview = new WebView(getApplicationContext());
webview.setWebChromeClient(new WebChromeClient() { ... });
webview.setWebViewClient(new WebViewClient() { ... });
...
webview.loadUrl("http://www.google.de");
}
The Webpage is opened, but if close the Activity on Back-Button pressed and go back to my main-menue, the WebView is not closed and the http-threads keep running.
If I open about 10 several pages one after another, the Webpages are not nonger loadet, but "Webpage not available" is displayd in the WebView.
I tried to close the thread by adding the code:
webview.destroy();
webview = null;
and
myLinearLayout = null;
and
Method op = Class.forName("android.webkit.WebView").getMethod("onPause",(Class[]) null);
op.invoke(webview, (Object[]) null);
But there is no change - the http-threads are still running.
What is wrong? How to close the WebView in the right way?
Thanx a lot for any suggestions!