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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.