Android SmsManager不发送短信
我试着用短信管理器发送短信。我有足够的权限。我浏览了Stackoverflow中给出的一些答案。这是我的密码。它在我的手机上工作,但不发送短信发送的短信显示“帮助我”。提前感谢Android SmsManager不发送短信,android,eclipse,Android,Eclipse,我试着用短信管理器发送短信。我有足够的权限。我浏览了Stackoverflow中给出的一些答案。这是我的密码。它在我的手机上工作,但不发送短信发送的短信显示“帮助我”。提前感谢 package com.example.esms; import android.app.Activity; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.
package com.example.esms;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
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 {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText textName = (EditText) findViewById(R.id.editText1);
final EditText textPhone = (EditText) findViewById(R.id.editText2);
Button buttonSend = (Button) findViewById(R.id.button1);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(textPhone.toString(), null, textName.toString(), null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
});
}
}
将textPhone.toString更改为textPhone.getText.toString,并将textName.toString更改为textName.getText.toString。非常感谢您的回答,它成功了。对不起,我为这么一个小问题打扰了你。我是android和java的婴儿。