Android activity jump Methods

Source: Internet
Author: User

1. display the call method

  • intent = new intent (this, otheractivity. Class); // method 1
  • intent intent2 = new intent ();
  • intent2.setclass (this, otheractivity. Class); // method 2
  • intent2.setclassname (this, "com. ZY. mutiactivity. otheractivity"); // method 3 this method can be used to open other applications
  • intent2.setcomponent (New componentname (this, otheractivity. Class); // Method 4
  • startactivity (intent2);
2. Call the method implicitly (as long as the action, category, data, and activity to jump to match in androidmanifest. XML, OK 3. After redirecting to another activity, data can be returned when the returned result is returned.
  • on the jump activity side, call startactivityforresult (intent2, 1) to jump to the next activity. The first parameter is the passed intent object, and the second is the Set Request Code;
  • after jumping to the second activity, call the setresult (100, intent) method to return the previous activity. The first parameter is the result code, and the second parameter is the passed-in intent object;
  • In the first activity, the onactivityresult () method is used to obtain the returned data.
Related Article

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.