Invoking built-in applications with intent
1. Create a new Android project and name it intents to add two buttons to the Main.xml file:
<button android:id= "@+id/btn_webbrowser" android:layout_width= "fill_parent" android:layout_ height= "Wrap_content" android:onclick= "Onclickwebbrowser" android:text= "Web Browser"/> < Button android:id= "@+id/btn_makecalls" android:layout_width= "fill_parent" android:layout_height= " Wrap_content " android:onclick=" onclickmakecalls " android:text=" make Calls "/>
2. Add the following code to the Intentsactivity.java file:
public void Onclickwebbrowser (View v) {//Browser Intent Intent = new Intent (Android.content.intent.action_view,uri.parse (" http://url "), or//url input Baidu URL, csdn do not let directly write the URL ... startactivity (intent); public void Onclickmakecalls (View v) {//Call Intent Intent = new Intent (Android.content.intent.action_dial,uri.parse (" tel:+651234567 ")); StartActivity (intent);}
3, the operation of the program, the effect is as follows:
Click Web Browser:
Click Make Calls:
Summarize:
In Android, the intent is usually an out-of-the-box: action and data. The action describes what to do and the data specifies the affected object.
Some examples of actions: Action_view, action_dial, Action_pick;
Some examples of data: tel:+651234567, geo:37.827500,-122.481670, content://contacts.