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