Android intent basic usage example

Source: Internet
Author: User

1: Open the webpage:

Uri uri = URI. parse ("http://www.baidu.com ");
Intent intent = new intent (intent. action_view, Uri );
Startactivity (intent );

2: Open the map:

Uri uri = URI. parse ("Geo: 136.46, 25.15 ");
Intent intent = new intent (intent. action_view, Uri );
Startactivity (intent );


3: outbound dialing:

Uri uri = URI. parse ("Tel: 13697336841 ");
Intent intent = new intent (intent. action_dial, Uri );
Startactivity (intent );


4. call:

Uri uri = URI. parse ("Tel: 13697336841 ");
Intent intent = new intent (intent. action_call, Uri );
Mainactivity. This. startactivity (intent );


5. send SMS:

Intent intent = new intent (intent. action_view );
Intent. putextra ("sms_body", "message content ");
Intent. settype ("Vnd. Android-DIR/MMS-SMS ");
Startactivity (intent );

6. send a text message (with a number ):


Uri uri = URI. parse ("smsto: 5554 ");
Intent intent = new intent (intent. action_sendto, Uri );
Intent. putextra ("sms_body", "message content ");
Startactivity (intent );


7. Send MMS
// Path of the image for sending MMS messages
Uri uri = URI. parse ("file: // sdcard/handou.png ");
Intent intent = new intent (intent. action_send );
Intent. putextra ("sms_body", "enter information here ");
// MMS attachment
Intent. putextra (intent. extra_stream, Uri );
// File type
Intent. settype ("image/PNG ");
Startactivity (intent );
8. send an email
String [] TOS = {"doctang@163.com "};
String [] CCS = {"tangmin@163.com "};
Intent intent = new intent (intent. action_send );
Intent. putextra (intent. extra_email, TOS );
Intent. putextra (intent. extra_cc, CCS );
Intent. putextra (intent. extra_text, "email body ");
Intent. putextra (intent. extra_subject, "Email Subject ");
// Intent. putextra (intent. extra_stream, "file: // sdcard/handou.png ");
Intent. settype ("text/plain ");
Startactivity (intent );


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.