<Android> talk about Android:configchanges properties from form leaks

Source: Internet
Author: User
Tags log log

Today, lucky to go to the big company to do a half-day temporary workers, an occasional bug toss him for a long time, finally caught the abnormal log log, the general meaning is android.view.windowleaked--form leakage. I checked the information on the Internet:

every activity on Android has a WindowManager form manager,A dialog box built on top of an activity, Popupwindow also has a corresponding WindowManager form manager. Because dialog , Popupwindown cannot be separated from activity and exist separately Span style= "FONT-FAMILY:VERDANA,GENEVA,ARIAL,HELVETICA,SANS-SERIF; font-size:14.44444465637207px; Line-height:20.98958396911621px "> (or Popupwindow) No normal exit, This dialog (or Popupwindow) WindowManager has no one to be affiliated with so its form manager is leaking out.

based on this information, the sudden turn screen when entering a new activity (the SDK developed by the man supports the screen switching) because the Android:configchanges attribute is not configured in Androidmanifest.xml. At this point the activity willThe OnCreate method is called again, and the entire life cycle is recalled, and the dialog is displayed without dismiss, causing the form to leak. The solution has become so simple,Configuring in Androidmanifest.xmlandroid:configchanges property, so that when we switch between the screen, the activity's The Onconfigurationchanged method does not re-invoke the entire life cycle. We finally configured the android:configchanges=" Screensize|orientation|keyboardhidden |navigation < Span style= "font-size:14.44444465637207px".


Since talking about the android:configchanges attribute, I have done further research, comprehensive online information, summed up:

1, do not set the activity of the android:configchanges, the screen will recall the entire life cycle, cut across the screen will be executed once, cut the vertical screen will be executed twice

2, set the activity android:configchanges= "orientation", the screen will recall the entire life cycle, cut horizontal, vertical screen will only be executed once

3, set the activity android:configchanges= "Orientation|keyboardhidden", the screen will not recall the entire life cycle, Only the Onconfigurationchanged method is executed

However, since the Android 3.2 (API 13), after setting the activity's android:configchanges= "Orientation|keyboardhidden", the same will recall the various lifecycles. Because the screensize also began to follow the device to switch between the changes. So if you want to prevent the program from reloading the activity at run time, in addition to setting the Minisdkversion and Targetsdkversion properties in Androidmanifest.xml that are greater than or equal to 13, Orientation ", you must also set the" ScreenSize ".

--The above information from the Internet to see, feel very useful, but I did not verify, but I believe is also the LZ verified issued, should be very useful.

Attach the android:configchanges attribute explanation:

value                         description                               &NBS P                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp      
"MCC" International Mobile Subscriber identification number The country code is changed-----SIM was detected, to update MCC MCC is the mobile user's country code
"MNC" The mobile network number of the International Mobile Subscriber ID is changed------SIM is detected, to update the MNC MNC is a mobile network number, up to two digits, to identify mobile users belong to the mobile communication network
"Locale" The address changed-----The user chose a new language that would show up
"Touchscreen" The touchscreen is changed------usually doesn't happen
"Keyboard" The keyboard has changed----such as the user using an external keyboard
"Keyboardhidden" The usability of the keyboard has changed
"Navigation" Navigation has changed-----usually does not occur
"Screenlayout" The display of the screen has changed------different displays are activated
"Fontscale" Font proportions have changed----Select a different global font
"Uimode" The user's pattern has changed
"Orientation" The screen orientation has changed.
"ScreenSize" The screen size has changed
"Smallestscreensize" The physical size of the screen has changed, such as: Connect to an external screen



















Today's harvest is not small, see the big company's domineering, but also deepened the android:configchanges attribute understanding.

<Android> talk about Android:configchanges properties from form leaks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.