[Android] the app flashes back on some Samsung hosts: "Do not reserve activity"

Source: Internet
Author: User

Today, users report that applications always crash.
Symptom: After mainactivity, any second-level Interface related to the main process will cause the application to crash (Note: It is not caused by a crash, but a crash)
Analysis: 1. Check the log and throw an exception before exiting. However, check the code to find that the exception has been caught and the exception information has been printed.
2. If it is suspected that every activity is implemented and its parent class baseactivity does something bad, a new custom activity does not inherit from its parent class. The activity still exists and exits. (Vinney, thanks)
3. It is found that the custom exitapp () of mainactivity is called every time and the breakpoint is set. It is found that it is initiated by ondestory (), while ondestory () is called by the system.
4. I suspect that the ondestory () of each activity will be called immediately after it disappears from the screen. I wrote a small demo for verification. I started to suspect that it was a machine problem.
5. The Google Keyword "Samsung activity flashback" has come out. I posted a smiling post at http://zhidao.baidu.com/question/493015963.html. Locate the cause.
Cause: the Samsung device has a "Developer option → do not retain activity (delete every activity immediately after the user leaves)", which will call mainactivity after entering and leaving from mainactivity. ondestory (), causing the exit Operation to crash (edit by sodino)
Resume: cancel the "do not retain activity" option.

Is there a solution that can be solved in the app even if "do not retain activity" is selected? Yes. ondestory () at mainactivity does not call the exit operation. May overwrite finish (). When the Code explicitly calls finish (), it will exit the application. However, there is still a disadvantage: When activity. ondestory () is returned from the second-level interface by pressing the return key to mainactivity, there will be a short black screen, and then it will be restored.

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.