Callback sequence after executing Setresult

Source: Internet
Author: User

A--> startactivityforresult--> B-->setresult does not perform the Finish method A is the Setresult method executed in B or B after the finish Onactivityresult method?

a--> startactivityforresult--> b-->setresult--> Finish If there is activity a in the middle of a and B in the stack will not be executed after (B Setresult and finish)   Onactivityresult method instead of executing the parameters immediately after a startactivityforresult resultcode to Result_cancel This situation may occur when a and B are not on the same stack (for example, the startup mode for B is Tan (details))


The correct invocation order is as follows

a--> startactivityforresult--> b-->setresult--> finish--> a-->onactivityresult-->onrestart--& Gt;onstart-->onresume


The Onactivityresult method annotation for the cause activity is as follows

/**
* Called when a activity you launched exits, giving you the Requestcode
* You started it with, the ResultCode it returned, and any additional
* Data from it. The <var>resultCode</var> would be
* {@link #RESULT_CANCELED} if the activity explicitly returned that,
* didn ' t return any result, or crashed during its operation.
*
* <p>you'll receive this call immediately before Onresume () when your
* Activity is re-starting.
*
* @param requestcode The integer request code originally supplied to
* Startactivityforresult (), allowing you to identify
* result came from.
* @param resultcode The integer result code returned by the child activity
* Through its setresult ().
* @param data an Intent, which can return result data to the caller
* (various data can be attached to Intent "extras").
*
* @see #startActivityForResult
* @see #createPendingResult
* @see #setResult (int)
*/

Execute the Onresume method before executing Onactivityresult test the OnStart method after Onactivityreult Onrestart should be the same

Conclusion Onactivityresult is performed in the execution life cycle method first.

Callback sequence after executing Setresult

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.