Symptoms:
When using Startactivityforresult to call the camera or select a picture, always onactivityresult return immediately, Resultcode=0 CANCEL.
Startactivityforresult (intent,image_pick_request);
Because it is in the fragment inside the use of startactivityforresult have problems, so began to think because fragment caused problems, all kinds of debugging can not solve the problem.
Workaround:
Then suddenly see manifests inside see activity was configured as SingleInstance, suddenly thought, may be this caused the problem, go to manifests inside to change it
Android:launchmode= "Singletop"
Startactivityforresult can be used normally.
Analysis Reason:
SingleInstance state, when the system loads any new activity, it moves the new activity to the new stack, keeping the activity in the stack that is set to singleinstance. So when set to SingleInstance, using Startactivityforresult, the system moves the newly initiated activity onto the new stack, and the original activity on the stack remains on top of the stack. So the return ResultCode is cancel. Because activity on other stacks cannot return data to activity on top of that stack.
As a replacement, the singleinstance can be swapped singletop to resolve the problem.
Android Debug Bug Collection Onactivityresult immediately returns and is cancel