Android development activity and intent

Source: Internet
Author: User

 

An intent object contains the following content:

1. component name: name of the activity to be started

2. Action

3. Data

4. Category

5. Extras

6. flags

First, initialize an internal class (listener class) in the first activity class, override onclick () method in the listener class, initialize the intent object in the listener class, and use the intent setclass () the object of the class to which the message is sent and the name of the target class. Use the startactivity (intent) method to send this intent, and finally bind the listener class object to a button, using setonclicklistener (new listener class ).

It should be noted that after an activity is created, a layout file (XML) of the activity is created. When the oncreate () method of the newly created activity is rewritten, setcontent (R. layout. layout file (XML) Method

Associate the activity class with the layout file. After creating an activity, you must register the activity in the androidmainfest. xml file.

Below is a text message sent by AndroidCode 

 

Uri uri = URI. parse ("Small sto: // 09998989");

Intent intent =NewIntent (intent. action_sendto, Uri );

Intent. putextra ("Sms_body","XX, how are you?");
Activity01.This. Startactivity (intent );

Write at the beginningProgramI did not know how to quickly import a class. Later I checked the information and found that eclipse had many shortcut keys. In my next blog, I summarized them. Also, pay attention to the matching between classes.

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.