Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/232.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android SmsManager不发送短信_Android_Eclipse - Fatal编程技术网

Android SmsManager不发送短信

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.

我试着用短信管理器发送短信。我有足够的权限。我浏览了Stackoverflow中给出的一些答案。这是我的密码。它在我的手机上工作,但不发送短信发送的短信显示“帮助我”。提前感谢

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的婴儿。