4

I created simple code to send SMS which is working on Xperia U and QMobile (local brand). But it is not working on Samsung Galaxy S3 LTE

They code is

import android.telephony.SmsManager;
SmsManager sms = SmsManager.getDefault();
            PendingIntent sentPI;
            String SENT = "SMS_SENT";

            sentPI = PendingIntent.getBroadcast(activity, 0,new Intent(SENT), 0);

            sms.sendTextMessage("01234567890", null, msg, sentPI, null);
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Adil Bhatty
  • 17,190
  • 34
  • 81
  • 118

3 Answers3

2

first be sure to add the permission to send SMSs

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

and then surround your code with try and catch to find the error that prevents sending in Samsung s3 lte ..

      try {
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage("01234567890", null, msg, sentPI, 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();
      }
Ahmed Ekri
  • 4,601
  • 3
  • 23
  • 42
0

You have missed to call PendingIntent deliveredPI

Try this code..!!

PendingIntent sentPI =PendingIntent.getBroadcast(activity, 0,new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,new Intent(DELIVERED), 0);
sms.sendTextMessage("01234567890", null, msg, sentPI, deliveredPI);
Dileep
  • 5,362
  • 3
  • 22
  • 38
0

You can try using this library android-smsmms to send SMS

Settings sendSettings = new Settings();
sendSettings.setDeliveryReports(true);
sendSettings.setSplit(true);
Message mMessage = new Message(textToSend, addressToSendTo);.
sendTransaction.sendNewMessage(message, null)

Hope this helps you

EDIT

com.klinker.android.send_message.Settings sendSettings = new com.klinker.android.send_message.Settings();
sendSettings.setDeliveryReports(true);
sendSettings.setSplit(true);
sendSettings.setSplitCounter(true);
sendSettings.setStripUnicode(true);
com.klinker.android.send_message.Transaction sendTransaction = new com.klinker.android.send_message.Transaction(getApplicationContext(), sendSettings);
com.klinker.android.send_message.Message mMessage = new com.klinker.android.send_message.Message("Message", "9999999999");
sendTransaction.sendNewMessage(mMessage, 0);
Girish Nair
  • 5,148
  • 5
  • 40
  • 61
  • It is showing error at sendTransaction and where is the message field declared in sendTransaction – Kartheek Sarabu Oct 29 '13 at 08:06
  • I am getting this error while executing my application `[2013-10-29 13:57:50 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/google/gson/JsonSerializer; [2013-10-29 13:57:50 - kluebook] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/gson/JsonSerializer;` – Kartheek Sarabu Oct 29 '13 at 09:59
  • It seems you have already asked this question in stack overflow http://stackoverflow.com/questions/19653132/message-is-not-sending-in-some-phones-by-smsmanager so wait for an answer. I would suggest you drop a mail to jklinker1@gmail.com who is the developer of this library. I think there is some problem with your development environment. – Girish Nair Oct 29 '13 at 10:17