Android Learning Note (17)--Invoke built-in application with intent

Source: Internet
Author: User

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.

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.