Android Learning Note (11) Intent

Source: Internet
Author: User
First, the basic concept of intent object

-intent is one of the Android application components
The-intent object represents an intention in the Android system
The most important part of-intent is action and data

Second, the basic use of intent object method

Intent Intent = new Intent ();
  Intent.setclass (Mainactivity.this,otheractivity.class);
Put the Putextra statement here to hold the data
StartActivity (Intent);

Third, using intent to transfer data between activity

-Store data in intent objects using the Putextra () series method
Intent.putextra ("Com.package.Age", 20);
The stored value is a key-value pair. The first parameter is the name, it needs to include the package name, and the second is a value
-Use the Getxxxextra () series method to extract data from the intent object (in another activity)
Intent Intent = Getintent ()
int age = Intent.getintextra ("Com.package.Age", 10);
XXX is the data type; The first parameter is the name, the package name is required, and the second parameter is the default value, which is the value returned by the data fetch failure.

Android Learning Note (11) Intent

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.