Sid Sid - 1 year ago 75
Android Question

Text message not getting sent. android

I am trying to send the message to multiple numbers. But message is not getting sent. I have added code to send the messages in a service to get execute even if app is in background.

Also added the permission in manifest. Asked for runtime permission.

Message Service:

public class MessageService extends Service {

ArrayList<String> numbers = new ArrayList<>();
private SharedPreferences sharedpreferences;
private String mUserName;

public int onStartCommand(Intent intent, int flags, int startId) {

sharedpreferences = getSharedPreferences("UserProfile", Context.MODE_PRIVATE);

mUserName = sharedpreferences.getString("UserUsername", "");

numbers = intent.getStringArrayListExtra("numbers");

for (String number:numbers) {


// sendSMS("8655864341","Hello");

return super.onStartCommand(intent, flags, startId);

public void sendMsg(final String num){
String SENT = "SMS_SENT";
final SmsManager sms = SmsManager.getDefault();
final PendingIntent sentPI = PendingIntent.getBroadcast(MessageService.this, 0,new Intent(SENT), 0);
Handler h = new Handler();
h.postDelayed(new Runnable() {
public void run() {
// sms.sendTextMessage(num, null, "Hi,I am " + mUserName + "add me to your unique contact list and you never need to update" +
// " any changes anymore! Click download below to download the App." + "", sentPI, null);

sms.sendTextMessage(num, null, "Hi,add me to your unique contact list and you never need to update" +
" any changes anymore! Click download below to download the App.", sentPI, null);
}, 3000);


This thing was working before, messages was getting received on the numbers, but now I tried to add the link and username in the message so it was not getting sent.

Then again I tried to remove link and username from message and checked if message is getting sent or not, so its not working now.

I also wanted to know how to add hyperlinks in SMS so that user can open a web page after clicking a link?

Can Anyone help me with this please? Thank you..

Answer Source

If the SMS messages were getting received in the past, but after attempting to send a hyperlink it doesn't work, it could be that the wireless provider you're using have blocked your SIM card for suspicious SMS traffic. Messages with links are often treated as spam.

Try to replace the SIM card and send a "Hello World" message once again.

The hyperlinks in SMS are recognized by the phone and the most smart phones make them clickable. So, just put the URL in SMS and recipients can click it. It works on iPhone and the most of Android phones.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download