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