Android sends SMS, MMS, and email code

Source: Internet
Author: User

1: send SMS

String body = "this is MMS Demo ";
Intent mmsintent = new intent (intent. action_sendto, Uri. fromparts ("smsto", number, null ));
Mmsintent. putextra (messaging. key_action_sendto_message_body, body );
Mmsintent. putextra (messaging. key_action_sendto_compose_mode, true );
Mmsintent. putextra (messaging. key_action_sendto_exit_on_sent, true );
Startactivity (mmsintent );

2: Send MMS

Stringbuilder sb = new stringbuilder ();
SB. append ("file ://");
SB. append (FD. getabsolutefile ());
Intent intent = new intent (intent. action_sendto, Uri. fromparts ("mmsto", number, null ));
// Below extra datas are all optional.
Intent. putextra (messaging. key_action_sendto_message_subject, subject );
Intent. putextra (messaging. key_action_sendto_message_body, body );
Intent. putextra (messaging. key_action_sendto_content_uri, SB. tostring ());
Intent. putextra (messaging. key_action_sendto_compose_mode, composemode );
Intent. putextra (messaging. key_action_sendto_exit_on_sent, exitonsent );
Startactivity (intent );

3: Send mail

Mime = "img/jpg ";
Using intent. setdataandtype (URI. fromfile (FD), mime );
Extends intent. putextra (intent. extra_stream, Uri. fromfile (FD ));
Specify intent. putextra (intent. extra_subject, subject );
Extends intent. putextra (intent. extra_text, body );

 

Post: http://hi.baidu.com/jiang_yy_jiang/blog/item/72191b00b7efa002738b6543.html

Slave --------------------------------------------------------------------------------------------------------------------------------

Development Using eclipse on Windows is different from development using Unix environment. You can use the following code on Windows to send the code. Make sure to modify the code yourself.
Intent intent = new intent (intent. action_send );
Intent. addflags (intent. flag_activity_new_task );
Intent. putextra ("Address", phnumber );
Intent. putextra ("compose_mode", false );
Intent. putextra ("exit_on_sent", true );
Intent. putextra ("subject", "MMS test ");
Intent. putextra ("sms_body", "this is MMS send auto ");
Intent. putextra (intent. extra_stream, Uri. parse ("file: // sdcard/ima.jpg "));
Intent. setclassname ("com. Android. MMS", "com. Android. mms. UI. composemessageactivity ");
Intent. settype ("image/JPEG ");

Startactivity (intent. createchooser (intent, "Send MMs "));

 

Post: http://www.eoeandroid.com/thread-21150-1-1.html

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

When sending an email:No application can perform this action or no application can perform this operation,

The following code solves the problem:

String mailId=(String)ContactUs.this.getString(R.string.contactus8); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts( "mailto",mailId, null)); //emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{mailId}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body); startActivity(emailIntent); 

Tip: http://www.coderanch.com/t/520651/Android/Mobile/no-application-perform-action-when

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.