1

I have the following problem with a WebView Control. My webview is defined in a Activity as follows:

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");
}

Everything works fine, the Webpage is opened. But if close the Activity (Back-Button pressed) and go back to my main-menue, the WebView seems not to be closed. The http-threads keeps 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.

What is wrong? How to close the WebView?

webview.destroy();
webview = null;

e.g. does not work.

J. Steen
  • 15,470
  • 15
  • 56
  • 63
S26
  • 13
  • 1
  • 4

2 Answers2

1

Do this:

In the onPause(), call webView.onPause(), and in onResume() call webView.onResume().

Teo Choong Ping
  • 12,512
  • 18
  • 64
  • 91
0

Try looking at this to see if it is the same issue and resolution.

How do I pause Flash content in an Android WebView when my activity isn't visible?

Community
  • 1
  • 1
vee
  • 720
  • 7
  • 8
  • Thanks for your answer. I did as you told me an call the webview.onPause in the onPause() of the Activity as follows: Class.forName("android.webkit.WebView").getMethod("onPause",(Class[]) null).invoke(webview, (Object[]) null); But the http-threads are still running. What is wrong? – S26 May 07 '11 at 05:10
  • Please can you post the whole source-code of a minimal example with the solution which is described in the link above? Thanx! – S26 May 08 '11 at 20:59
  • Problem seemed to be to less RAM on Emulator-Device. – S26 May 13 '11 at 04:59