Automatic SMS Not Sending

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 8

Aug 29, 2018, 5:20:39 PM via Website

Just when i thought i had all things wrapped up then Murphy's law kicks in. Now ive seen posts elsewhere and am completely baffled why this is not working. I am trying to automatically send out an SMS from my android app but it registers a failed message on the mobile phone. I have included in my manifest uses permission for SEND_SMS

uses-permission android:name="android.permission.SEND_SMS"/

The code itself is

//Imports

import android.telephony.SmsManager;

//Variables inside my MainActivity class
String phoneNumber = "+27XXXXXXXXX"//9 digits of my cell number excluding the 0
String smsMessage ="My Message";

private void sendSMS(String phoneNo,String msg){
try{
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNo, null, msg, null, null);
}
catch(Exception ex){
display.setText(ex.toString());
}
}

Reply
  • Forum posts: 8

Sep 3, 2018, 12:44:30 PM via Website

Hi

Found out what was the cause. The android device i tested the app on had two SIM cards. SIM2 had airtime whilst there was none on SIM1 which was the default SIM for sending out SMS and MMS messages. I simply changed the setting on the phone to send SMS from SIM2 so SMS messages are now being delivered.

Helpful?
Reply

Recommended articles