SMSManager does not work on Samsung Galaxy S3 LTE

I created a simple code for sending SMS that works on Xperia U and QMobile (local brand). But it does not work on Samsung Galaxy S3 LTE

They have a code

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); 
+4
source share
3 answers

first, be sure to add permission to send SMS messages

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

and then combine your code with try and catch to find an error that prevents sending to 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(); } 
+2
source

You missed the 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); 
0
source

You can try using this android-smsmms library 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); 
0
source

Source: https://habr.com/ru/post/1498351/


All Articles