In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to solve memory leaks when using webview in Android", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this article "how to solve memory leaks when using webview in Android".
1. Avoid writing webview controls directly in xml, which references activity, so write a LinearLayout in xml, and then linearLayout.addView (new MyWebview (getApplicationContext ()
In this way, dynamic generation of webview can avoid memory leaks, but this will cause some models of webview to click on the hyperlink and cause the program to crash. The temporary solution is to prohibit clicks and need to rewrite webview.
Public class MyWebview extends WebView {public MyWebview (Context context) {super (context);} public MyWebview (Context context, AttributeSet attrs) {super (context, attrs);} public MyWebview (Context context, AttributeSet attrs, int defStyleAttr) {super (context, attrs, defStyleAttr);} @ Override public boolean onTouchEvent (MotionEvent event) {return false;}}
This avoids program crashes.
Manual release of webview memory is required when 2.activity is closed
@ Override protected void onDestroy () {super.onDestroy (); if (webview_projectinfo! = null) {webview_projectinfo.removeAllViews (); webview_projectinfo.destroy (); webview_projectinfo = null; ll_webview.removeAllViews (); ll_webview = null }} the above is about the article on "how to solve memory leaks when using webview in Android". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.