Acitivity Method of Intent call

Source: Internet
Author: User

With intent, you can switch between two pages (Activity). Of course, using intent can also be implemented to start a service, and to initiate a broadcast broadcasts.

① noun Explanation:
Chinese meaning is: intention, purpose; Meaning, meaning. That is, when a activity,service or broadcasts to express the intention of an action, use the intent to make a mediator between their communication. Intent is a run-time binding (runtime bindings) mechanism. With intent, your program can express some kind of request or intention to Android, and Android will choose the appropriate component to respond to the desired content.

The ② simply implements the switch between the activity.

/*mainactivity.java*/

 Button1.setonclicklistener (new   Onclicklistener () {@Override  public  
   
    void  
     OnClick (View v) { 
    // Create a Intent object  Intent Intent = new
    Intent (); Intent.setclass (mainactivity.  this , otheractivity. class ); //  stand-alone button, jump from the current mainactivity to otheractivity  startactivity (i       Ntent); //  

The problem with this jump is that the jump between the two acitivity is not "bound" because intent is a runtime binding mechanism. This has some benefits, but after entering another page (Activity), you need to press the back key to return to the previous page. This is to say: if the entire application uses a lot of intent such a jump mechanism, to return to the homepage is very troublesome.

③ "Intent" is more powerful than you think.

The intent has several properties:

Action, data, category, type, Component (Compent), and extended letter (Extra). The most common of these are the Action property and the Data property.

Give me a chestnut.

Btn01.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {Intent Intent=NewIntent (); Intent.setaction (intent.action_get_content);//Set Intent Action propertyIntent.settype ("Vnd.android.cursor.item/phone");//Setting the intent Type property//The main is to get the contents of the Address BookStartActivity (Intent);//Start Activity            }          }); 

The above method is implemented: Click the button btn01 after the phone to bring your own contacts, select the interface of the contact person.

Other detailed explanations of intent usage See blog: http://liangruijun.blog.51cto.com/3061169/634411

Explanations of vnd.android.cursor.item/in Android see: http://blog.sina.com.cn/s/blog_746189210102vzvr.html

Acitivity Method of Intent call

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.