Android Intent Implementation Page jump

Source: Internet
Author: User

Intent can assist in the completion of communication between various Android components 1:startactivity (intent); Direct start               /** A second activity by listening to a click event Jump set               */               Button= (Button) Findviewbyid (r.id. button1);               Button. Setonclicklistener ( New Onclicklistener () {                      @Override                      Public void OnClick (View v) {Intent intent= New Intent (mainactivity. This , myactivity.class);                            //Through the startactivity way to achievemainactivity. This. StartActivity (intent);                     }              });2:startactivityforresult (Intent,requestcode);     After startup there is a return value, need to correlate onactivityresult (a page use), Setresult (b page use) two methods. Onactivityresult (int requestcode,int resultcode,intent data) Setresult (Resultcode,data);Button2= (Button) Findviewbyid (r.id.Button2);               Button2. Setonclicklistener ( New Onclicklistener () {                                           @Override                      Public void OnClick (View v) {                            // TODO auto-generated Method StubIntent intent= New Intent (mainactivity. This , myactivity.class);                            /** The first parameter is a intent object* The second parameter is the requested identity                            */Startactivityforresult (Intent, 1);                     }              });      /*** Method of receiving return data via Startactivityforresult jump* Requestcode: The identity of the request* ResultCode The identity returned by the second page* Data returned from the second page        */        @Override        protected void Onactivityresult (int Requestcode, int ResultCode, Intent data) {                Super. Onactivityresult (Requestcode, ResultCode, data);               if(requestcode==1&&resultcode==2) {String content=data.getstringextra ("Data");              }       }

Android Intent Implementation Page jump

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.