android WebView停止运行
我的 WebView 控件遇到以下问题。 我的 webview 在 Activity 中定义如下:
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");
}
一切正常,网页已打开。但是,如果关闭活动(按下后退按钮)并返回到我的主菜单,WebView 似乎不会关闭。 http 线程继续运行。
如果我依次打开大约10个页面,网页不再加载,但WebView中显示“网页不可用”。
怎么了?如何关闭WebView?
webview.destroy();
webview = null;
例如不起作用。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试查看此内容,看看是否是相同的问题和解决方案。
怎么做当我的 Activity 不可见时,我会暂停 Android WebView 中的 Flash 内容吗?
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?
这样做:
在onPause()中,调用webView.onPause(),在onResume()中调用webView.onResume()。
Do this:
In the onPause(), call webView.onPause(), and in onResume() call webView.onResume().