Android Debug Bug Collection Onactivityresult immediately returns and is cancel

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.