Android-intent (intention) use-< two >

Source: Internet
Author: User

1. Intent (intention)

Intent is a set of information that abstractly describes what behavior you want to perform. It is an object that contains a set of information.

Through it, you can start another activity (StartActivity method); Broadcastintent spread Intent to

Broadcastreceiver components; start-up service: StartService (Intent); Bindservice (..) Go with the backstage

Service communication.

The basic function of 2.Intent (It is an object that contains a set of information)

1.Component name : which Activityto start.

2.Action : For The operation after initiating the Activity.

3.Data : What data do you pass into the specified Activity

4.Extras : Stores a key-value pair and passes it to the specified Activity.

5.Category

6.Flags

/** Demo with one activity (click button to go to another interface) start another activity with intent * 1. Register a button * 2 in this activity. Add a Oncliklistener listener to the button  * 3. Write a jump to other activity code on the listener * 3.1 Create a new Intent object, call the SetClass method, and pass in the parameter * 3.2 of the other activity to call the StartActivity (Intent Intent) method. * 4. Note: Another activity needs to create a new XML layout file and register it in the manifest file. */ Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);        Setcontentview (R.layout.main); Button BT=(Button) Findviewbyid (R.id.mybutton); Bt.settext ("Otheractivity"); Bt.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method StubIntent intent=NewIntent (); Intent.setclass (androidprojecttest1activity. This, Otheractivity.class); Androidprojecttest1activity. This. StartActivity (Intent);    } }); }

Android-intent (intention) use-< two >

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.