Android SMS not working

筅森魡賤 提交于 2019-12-13 07:00:41

问题


Below is my code for sending a SMS message. My phone number is 614xxxxxxx. I try typing +1614xxxxxxx or 1614xxxxxxx or 614xxxxxxx for the number and some text for the message. No error shows up but my phone cannot get the message?

 protected void sendMessage(){
        String number=no.getText().toString();
        String message=msg.getText().toString();

        SmsManager manager=SmsManager.getDefault();
        manager.sendTextMessage(number, null, message, null, null);

}

回答1:


The call you are making is right. Did you add the SEND_SMS permission? This must be done on the manifest. You can read a good tutorial here: http://www.tutorialspoint.com/android/android_sending_sms.htm

It also has an example



来源:https://stackoverflow.com/questions/36164118/android-sms-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!