Android's Startactivityforresult

Source: Internet
Author: User

one: Common jump implementations between activity in Android

1) startactivity (Intent Intent);

2) Startactivityforresult (Intent Intent, int requestcode);

The difference is that (2) data can be returned. Such as:


II: Instructions for use

startActivityForResult(Intent intent, int requestCode)
Start multipleActivitya,B, C, available through requestcode determine the difference;
setResult(resultCode);
functionA, B, Cwhen returned, by resultcode difference;
@Override    protected voidOnactivityresult(intRequestcode, intResultCode, IntentData) {< Span class= "PLN" style= "Color:rgb (72,72,76)" >        super  onactivityresult   ( requestcode     ResultCode     data       }
  • through requestcode and ResultCode determination of data;

    Three: precautionsonbackpressed () callSetresult ();

    OnDestroy () call setresult ();

    < Span style= "font-size:18px" > contrast style= font-size:14px "; Color:windowtext; Font-family:consolas ">onactivityresult style= font-size:14px; Color:windowtext; Font-family:consolas ">activity-b onPause () activity-a Onrestart () Before the function is called.

    so setresult () needs to be OnPause () function is called before the onStop () or OnDestroy () function cannot return data.

    Four: extension

    onStop () and the OnDestroy () do cleanup, release resources, and not pass data.


    Android's Startactivityforresult

    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.