Today I found a problem that is easy to make mistakes and concealed.
In androidmenifest. XML, two types of activity A, B, and Cycler C are defined.
A defines a public static variable.
A sends a broadcast at a certain time. After the receiver receives the broadcast, it sends an intent to start B.
B changes the value of static variable a during running. When B exits, A is returned. In a, the value of a is read, and the result is still unchanged. That is to say, the value of B's change of A is invalid.
I haven't understood it for a long time. Obviously, a is a static variable and directly uses. a's access. After the operation in B, the log has been changed, but the log in a has not changed!
Later I thought of a problem. When I defined a in androidmenifest. XML, I set the Android: Process = "A" value, but not in B. Therefore, Activity A and Activity B run in different process spaces!
Static variables are two irrelevant variables in different processes compared to the same process!
I would like to remind myself that I encountered a similar problem next time and checked whether I made the same mistake.