S 26
- Forum-Beiträge: 1
07.05.2011, 17:49:36 via Website
07.05.2011 17:49:36 via Website
Hello,
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.
I tried to close the thread by adding the code:
webview.destroy();
webview = null;
or
myLinearLayout = null;
or
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? webview.destroy(); webview = null; e.g. does not work.
Thanx a lot for any suggestions!
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.
I tried to close the thread by adding the code:
webview.destroy();
webview = null;
or
myLinearLayout = null;
or
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? webview.destroy(); webview = null; e.g. does not work.
Thanx a lot for any suggestions!
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.