Encounter a situation:
In a timer, the network request query order payment status is initiated once per second, if the payment is successful, a message is sent in response;
If the message is received in handler, control the fragmentation switch.
The result encountered an error: The Fragment switch transaction error, there is a null object call BeginTransaction ().
Cause: Because the timer makes a request every second, the response of the network request from the last second is not returned, the next second is issued; results after the response of the last request arrives, the fragmentation switch is controlled, and the Fragment object is replaced (but not destroyed), and the response of the second network request is returned after the page switchover. So the fragments that were replaced still emit information based on the response result, and the handler response information controls the fragmentation switch, at which point the fragment is not in any activity and therefore cannot get the Shard Manager through Getfragmentmanager (), so at this point Getfragmentmanager (). BeginTransaction () will have an error.
Workaround: Control how often network requests are made
In the timer, add a judgment condition, every 5 seconds (self-determined, long enough), send a network request.
android--Fragmentation Transaction call failed