当前位置:网站首页>WebView error

WebView error

2022-06-22 03:52:00 One stop to s

WebView.destroy() called while WebView is still attached to window.

resolvent :

Now sum up the solution to this problem . First, explain the mistake roughly , This mistake literally means when you end up webview When ,Webview Also attached to the parent control , Use to solve this problem

Is in the WebView.destroy() We should remove the attachment between them . This problem usually happens. It should be like this webview It's operated :
protected void onDestroy()
{
    if (adView != null)
    {
        adView.destroy();
    }
}

Attach a detailed correct code :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webviewRelativeLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
 
<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/headerAlarmsWebViewTxt"
    android:layout_marginBottom="0dip"
    android:hapticFeedbackEnabled="true"
    android:overScrollMode="never"
    android:scrollbarAlwaysDrawVerticalTrack="false"
    android:scrollbars="none" />
 
 </RelativeLayout>
Then you assign it to an instance variable e.g. :
 
_layout = (RelativeLayout) findViewById(R.id.webviewRelativeLayout);
webView = (WebView) findViewById(R.id.webView1);
and on Destroy do something like this:
 
@Override
protected void onDestroy() {
    super.onDestroy();
    _layout.removeView(webView);
    webView.removeAllViews();
    webView.destroy();
}

Generally, you can understand the problem after reading this code .

Reprinted address :

(136 Bar message ) Error: WebView.destroy() called while still attached Solutions for _ Geek Park blog -CSDN Blog

原网站

版权声明
本文为[One stop to s]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220322437539.html