Invoking built-in applications with intent
1. Create a new Android project named intents and 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, for example:
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 implementation of procedures, such as the following:
Click Web Browser:
Click Make Calls:
Summarize:
In Android, the intent is generally an out-of-the-box: action and data. The action description describes what to run, and the data specifies the affected object.
Some demonstration examples of actions: Action_view, action_dial, Action_pick;
Some demo examples of data: tel:+651234567, geo:37.827500,-122.481670, content://contacts.
Android Learning Note (17)--Invoke built-in application with intent