Summary of Android intractable diseases

When writing Android applications, sometimes we will encounter some intractable diseases, but often the solution is very simple. Here is a summary of the problems I encountered.
Question 1 : Login interface to the main interface after login. Log out of the main interface and jump to the login interface, the login interface crashes, but no crash problem is displayed on the console

Solution: After the final inspection, it was found that system.exit(0) was written in the ondestroy method of the activity on the main interface, and it will be fine after logout

Question 2 : In a fragment -- "another fragment, then jump to –" the third fragment, press the system's back key, and find that when returning to the second fragment, press the back key to intercept the monitoring in the fragment return key method

Solution: Because the system back key directly returns to the previous interface, the second fragment is not focused by default at this time, so the back return key cannot be monitored. Usually, in applications with fragments, pressing the system return key is done twice Click to exit the application. When multiple fragments jump, it is best to use a separate activity in the mobile version.

Guess you like

Origin blog.csdn.net/ligaoyuan8030/article/details/105688671