Solve the problem that the hidden display of the virtual key on the android phone causes the Activity to be recreated and flash back to the desktop

Let me talk about the problem first: when the app clicks the back button or returns on the toolbar, occasionally the app will fall back to the desktop but the exception is not caught.

In fact, this problem has been in the blogger project for a long time, and I can't find the reason. At first, I thought it was a problem with the stack, and then I gave up after looking for a while, because I couldn't find the problem. Then I suddenly found that one day it was caused by the display and hiding of the virtual navigation key, and then I immediately located the problem, and the solution was even simpler;

In the configuration file, the configChanges of the activity that needs not to be recreated under AndroidManifest.xml can be

            android:configChanges="screenLayout"

If there are multiple attributes like this:

            android:configChanges="keyboardHidden|screenLayout"

Guess you like

Origin blog.csdn.net/fzkf9225/article/details/87277372