Android Note: OnDestroy () bug cannot be executed immediately after the call to finish ()

Source: Internet
Author: User

The project uses the microblog SDK to return when the current activity calls the finish () but cannot immediately execute the OnDestroy (), troubleshooting the source of the problem for a long time still found. Baidu is still really able to solve through this method, make a note it. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0012.gif "alt=" J_0012.gif "/>



in the current project (android2.0), a serious bug was found. When a A, B two page is opened, at this time the current page is B., if after the call to finish () in B, although has returned to a, but B did not execute the OnDestroy () method, only on the phone after a certain button is pressed, then the B.ondestroy () will be executed. B will be completely destroyed. Another: This does not happen if you press the Back button that comes with your phone.

Therefore, if there are some operations at this time in the OnDestroy () method, then in return to a do not do the key operation, B is not destroyed in time, so do not do these operations in the method.

After the location modification, it was found that the bug was due to the android:theme= "@android: Style/theme.notitlebar" on page A in androidmanifest.xml. The B-page does not have this parameter set. After adding this setting to B, the problem is resolved.

Although the problem has been resolved, but has not been understood not set Android:theme= "@android: Style/theme.notitlebar" page, why the finish () can not immediately call OnDestroy (). It is supposed that there should be no correlation between the two.


Reference: http://blog.sina.com.cn/s/blog_5da93c8f0101nrx5.html




This article from the "Sky no traces but I flew" blog, please be sure to keep this source http://glblong.blog.51cto.com/3058613/1697132

Android Note: OnDestroy () bug cannot be executed immediately after the call to finish ()

Related Article

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.