The ondestroy () Bug cannot be executed immediately after you call finish () in Android.

Source: Internet
Author: User

A serious bug was found in the current project (android2.0. When the and B pages are opened, the current page is B. If finish () is called in B, however, B does not execute the ondestroy () method. B is executed only when a key is pressed on the mobile phone. ondestroy (). B will be completely destroyed. In addition, if you press the return button that comes with your mobile phone, this will not happen.

Therefore, if there are some operations in the ondestroy () method at this time, B will not destroy them in time if the return to a does not perform the key operation, so no such operations will be performed in the method.

After positioning and modification, we found that this bug was caused by setting Android: theme = "@ Android: style/theme. notitlebar" On page a in androidmanifest. xml ". This parameter is not set on page B. After adding this setting to B, the problem is solved.

Although the problem has been solved, I have never understood that Android: theme = "@ Android: style/theme is not set. why can't ondestroy () be called immediately after finish () on the notitlebar page (). It is reasonable to say that there should be no association between the two.

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.