Android Send SMS

Source: Internet
Author: User

Using Android to send text messages, you need to first add the send, read the text message new permissions:

   

 < uses-permission         Android:name = "Android.permission.RECEIVE_SMS" />       < uses-permission         Android:name = "Android.permission.SEND_SMS" />

Then need to add a two edittext in the interface, to add the sent number and send the content, and then add a button to trigger the operation of sending SMS, the code is not affixed, directly in the visual interface drag

Then get the Send button object in activity and rewrite its Setonclicklistener method with the following code:

 

Button send=(Button) Findviewbyid (r.id.send); Send.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method StubSmsmanager smsmanager=Smsmanager.getdefault (); Intent sendintent=NewIntent ("Sent_sms_action"); Pendingintent Pi=pendingintent.getbroadcast (mainactivity. This, 0, sendintent, 0); Smsmanager.sendtextmessage (the number sent,NULL, send the content, PI,NULL); }        });

Android Send SMS

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.