==================== Problem Description ====================
This code is the activity inside the layout of I do not post, I set the toast have been reported, but the text message still can not be sent out.
Package com.example.message;import android.app.activity;import android.app.pendingintent;import android.content.intent;import android.os.bundle;import android.telephony.smsmanager;import android.util.Log;import android.view.Menu;import android.view.View;import Android.view.view.onclicklistener;import android.widget.button;import android.widget.edittext;import android.widget.Toast;public class MainActivity extends Activity {public button send;public edittext number,message; @Overrideprotected void oncreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); send = (Button) This.findviewbyid (r.id.send);number = (EditText) This.findviewbyid (R.id.number); message = (EditText) This.findviewbyid (r.id.msg); Send.setonclicklistener (New onclicklistener () {@ Overridepublic void onclIck (view arg0) {// todo auto-generated method stubsendmessage ();});} Public void sendmessage () {String pnumber = number.gettext (). toString (). Trim (); String msg = message.gettext (). toString (). Trim (); pendingintent sentintent = pendingintent.getbroadcast (This, 0, new intent (), 0), if ("". Equals (msg) | | "". Equals (Pnumber)) {Toast.maketext (this, "need to fill in the number, cut text message content cannot be empty", toast.length_long). Show (); ELSE{LOG.I ("Message", "Recipient:" +pnumber+ " info:" +msg "); Smsmanager sms = smsmanager.getdefault (); Sms.sendtextmessage (pnumber, "13652179825", Msg, sentintent, null); toast.maketext (this, "sent successfully! ", toast.length_long). Show ();}} @Overridepublic boolean oncreateoptionsmenu (Menu menu) {// inflate the menu ; this adds items to the action bar if it is&nbsP;present.getmenuinflater (). Inflate (r.menu.main, menu); return true;}}
I added the authority Android.permission.SEND_SMS also put other related text messages and MMS permissions are added, but log inside prompted permission denied, because my virtual machine has a problem my test using the real machine. I am very short of knowledge in Android, but also ask the gods to see what is the line?
==================== Solution 1====================
Sms.sendtextmessage (This is the address of the recipient, NULL, MSG, send, NULL); You try this. The second parameter is the SMS Service center phone, and you wrote it wrong. should be null
==================== Solution 2====================
You debug to see what happens when it executes Logcat, the second parameter is the service center,
==================== Solution 3====================
Your phone is not loaded with 360 of such management software, so you blocked the action of short message
Android texting program, but no effect.