开发者

android WebView stop running

开发者 https://www.devze.com 2023-03-03 05:30 出处:网络
I have the following problem with a WebView Control. My webview is defined in a Activity as follows: public class MyWebView extends Activity {

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.


Do this:

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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号