
- Forum posts: 8
Aug 29, 2018, 5:20:39 PM via Website
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());
}
}