Sending sms error Generic failure again and agian












0















Here is my code..



private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

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

PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);

// ---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
ContentValues values = new ContentValues();
//for (int i = 0; i < MobNumber.size() - 1; i++) {
// values.put("address", MobNumber.get(i).toString());// txtPhoneNo.getText().toString());
// values.put("body", MessageText.getText().toString());
//}
getContentResolver().insert(
Uri.parse("content://sms/sent"), values);
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));

// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}


I am not sending so many SMSs at a time. I am not sending it fast. This code is under activity which extends AppCompactActivity. I have read all the links about this error on this site. I can't even send one sms. My mobile account balance is enough to send sms. My network service is also fine and I can send and receive sms. just getting one error "Generic failure". Please help me if any one have any idea.










share|improve this question























  • stackoverflow.com/questions/9769095/… read this

    – SAM
    Apr 7 '16 at 13:13











  • I have imported android.telephony.SmsManager;

    – Asad
    Apr 7 '16 at 13:16











  • I already read that link @SAM

    – Asad
    Apr 7 '16 at 13:20











  • @Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

    – Asad
    Apr 7 '16 at 13:24











  • I have checked and changed the number a thousand times.. @Mike

    – Asad
    Apr 7 '16 at 14:06
















0















Here is my code..



private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

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

PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);

// ---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
ContentValues values = new ContentValues();
//for (int i = 0; i < MobNumber.size() - 1; i++) {
// values.put("address", MobNumber.get(i).toString());// txtPhoneNo.getText().toString());
// values.put("body", MessageText.getText().toString());
//}
getContentResolver().insert(
Uri.parse("content://sms/sent"), values);
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));

// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}


I am not sending so many SMSs at a time. I am not sending it fast. This code is under activity which extends AppCompactActivity. I have read all the links about this error on this site. I can't even send one sms. My mobile account balance is enough to send sms. My network service is also fine and I can send and receive sms. just getting one error "Generic failure". Please help me if any one have any idea.










share|improve this question























  • stackoverflow.com/questions/9769095/… read this

    – SAM
    Apr 7 '16 at 13:13











  • I have imported android.telephony.SmsManager;

    – Asad
    Apr 7 '16 at 13:16











  • I already read that link @SAM

    – Asad
    Apr 7 '16 at 13:20











  • @Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

    – Asad
    Apr 7 '16 at 13:24











  • I have checked and changed the number a thousand times.. @Mike

    – Asad
    Apr 7 '16 at 14:06














0












0








0








Here is my code..



private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

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

PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);

// ---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
ContentValues values = new ContentValues();
//for (int i = 0; i < MobNumber.size() - 1; i++) {
// values.put("address", MobNumber.get(i).toString());// txtPhoneNo.getText().toString());
// values.put("body", MessageText.getText().toString());
//}
getContentResolver().insert(
Uri.parse("content://sms/sent"), values);
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));

// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}


I am not sending so many SMSs at a time. I am not sending it fast. This code is under activity which extends AppCompactActivity. I have read all the links about this error on this site. I can't even send one sms. My mobile account balance is enough to send sms. My network service is also fine and I can send and receive sms. just getting one error "Generic failure". Please help me if any one have any idea.










share|improve this question














Here is my code..



private void sendSMS(String phoneNumber, String message) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";

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

PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);

// ---when the SMS has been sent---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
ContentValues values = new ContentValues();
//for (int i = 0; i < MobNumber.size() - 1; i++) {
// values.put("address", MobNumber.get(i).toString());// txtPhoneNo.getText().toString());
// values.put("body", MessageText.getText().toString());
//}
getContentResolver().insert(
Uri.parse("content://sms/sent"), values);
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));

// ---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver() {
@Override
public void onReceive(Context arg0, Intent arg1) {
switch (getResultCode()) {
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
}


I am not sending so many SMSs at a time. I am not sending it fast. This code is under activity which extends AppCompactActivity. I have read all the links about this error on this site. I can't even send one sms. My mobile account balance is enough to send sms. My network service is also fine and I can send and receive sms. just getting one error "Generic failure". Please help me if any one have any idea.







android android-activity sms smsmanager






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 7 '16 at 13:09









AsadAsad

482716




482716













  • stackoverflow.com/questions/9769095/… read this

    – SAM
    Apr 7 '16 at 13:13











  • I have imported android.telephony.SmsManager;

    – Asad
    Apr 7 '16 at 13:16











  • I already read that link @SAM

    – Asad
    Apr 7 '16 at 13:20











  • @Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

    – Asad
    Apr 7 '16 at 13:24











  • I have checked and changed the number a thousand times.. @Mike

    – Asad
    Apr 7 '16 at 14:06



















  • stackoverflow.com/questions/9769095/… read this

    – SAM
    Apr 7 '16 at 13:13











  • I have imported android.telephony.SmsManager;

    – Asad
    Apr 7 '16 at 13:16











  • I already read that link @SAM

    – Asad
    Apr 7 '16 at 13:20











  • @Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

    – Asad
    Apr 7 '16 at 13:24











  • I have checked and changed the number a thousand times.. @Mike

    – Asad
    Apr 7 '16 at 14:06

















stackoverflow.com/questions/9769095/… read this

– SAM
Apr 7 '16 at 13:13





stackoverflow.com/questions/9769095/… read this

– SAM
Apr 7 '16 at 13:13













I have imported android.telephony.SmsManager;

– Asad
Apr 7 '16 at 13:16





I have imported android.telephony.SmsManager;

– Asad
Apr 7 '16 at 13:16













I already read that link @SAM

– Asad
Apr 7 '16 at 13:20





I already read that link @SAM

– Asad
Apr 7 '16 at 13:20













@Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

– Asad
Apr 7 '16 at 13:24





@Mike Sorry but I didn't understand your question, what is it means?? can you please explain ? The message is "this is a test". 14

– Asad
Apr 7 '16 at 13:24













I have checked and changed the number a thousand times.. @Mike

– Asad
Apr 7 '16 at 14:06





I have checked and changed the number a thousand times.. @Mike

– Asad
Apr 7 '16 at 14:06












5 Answers
5






active

oldest

votes


















2














I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.






share|improve this answer































    1














    If your message is too long then use handler inside your code



    new Handler().postDelayed(new Runnable() {
    public void run() {

    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
    }
    }, 1000*40);


    or use this link






    share|improve this answer


























    • I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

      – Asad
      Apr 7 '16 at 13:19













    • Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

      – Naveed Akhtar
      Apr 7 '16 at 13:27













    • I have just tried but still not working.

      – Asad
      Apr 7 '16 at 13:38











    • Ohhh....U need that delivery report and all?

      – Naveed Akhtar
      Apr 7 '16 at 13:39











    • no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

      – Asad
      Apr 7 '16 at 13:41





















    1














    If you are using a Dual Sim Phone, please check if Preferred Sim for SMS, is IS NOT set to "Ask every time".



    You need to set a default SIM. if you are using



    SmsManager sms = SmsManager.getDefault();






    share|improve this answer































      0














      If your phone is dual sim than first you need to set a preferred sim for sms in your phone setting (google it) and that default sim must be contain some balance amount...the other short trick to set preferred default sim in your phone is-just turn one sim off for some time so another sim will automatically become your preferred default sim for sms :)
      The phone number parameter in sendTextMessage() can be used in both ways i.e with country code like +919783###### or without code like 9783######. both will work






      share|improve this answer































        0














        Your message might be too long. In that case, you should use divideMessage and sendMultipartTextMessage, like this:



        smsManager.sendMultipartTextMessage(phoneNumber, null, divideMessage(message), null, null);





        share|improve this answer























          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36477226%2fsending-sms-error-generic-failure-again-and-agian%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.






          share|improve this answer




























            2














            I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.






            share|improve this answer


























              2












              2








              2







              I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.






              share|improve this answer













              I think you need to check the message center number. If it is not set or correct than this failure may happen. You will found this number at the SMS settings option.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 16 '16 at 10:17







              user6340214
































                  1














                  If your message is too long then use handler inside your code



                  new Handler().postDelayed(new Runnable() {
                  public void run() {

                  SmsManager sms = SmsManager.getDefault();
                  sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
                  }
                  }, 1000*40);


                  or use this link






                  share|improve this answer


























                  • I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                    – Asad
                    Apr 7 '16 at 13:19













                  • Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                    – Naveed Akhtar
                    Apr 7 '16 at 13:27













                  • I have just tried but still not working.

                    – Asad
                    Apr 7 '16 at 13:38











                  • Ohhh....U need that delivery report and all?

                    – Naveed Akhtar
                    Apr 7 '16 at 13:39











                  • no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                    – Asad
                    Apr 7 '16 at 13:41


















                  1














                  If your message is too long then use handler inside your code



                  new Handler().postDelayed(new Runnable() {
                  public void run() {

                  SmsManager sms = SmsManager.getDefault();
                  sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
                  }
                  }, 1000*40);


                  or use this link






                  share|improve this answer


























                  • I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                    – Asad
                    Apr 7 '16 at 13:19













                  • Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                    – Naveed Akhtar
                    Apr 7 '16 at 13:27













                  • I have just tried but still not working.

                    – Asad
                    Apr 7 '16 at 13:38











                  • Ohhh....U need that delivery report and all?

                    – Naveed Akhtar
                    Apr 7 '16 at 13:39











                  • no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                    – Asad
                    Apr 7 '16 at 13:41
















                  1












                  1








                  1







                  If your message is too long then use handler inside your code



                  new Handler().postDelayed(new Runnable() {
                  public void run() {

                  SmsManager sms = SmsManager.getDefault();
                  sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
                  }
                  }, 1000*40);


                  or use this link






                  share|improve this answer















                  If your message is too long then use handler inside your code



                  new Handler().postDelayed(new Runnable() {
                  public void run() {

                  SmsManager sms = SmsManager.getDefault();
                  sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
                  }
                  }, 1000*40);


                  or use this link







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 23 '17 at 12:23









                  Community

                  11




                  11










                  answered Apr 7 '16 at 13:17









                  Naveed AkhtarNaveed Akhtar

                  1316




                  1316













                  • I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                    – Asad
                    Apr 7 '16 at 13:19













                  • Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                    – Naveed Akhtar
                    Apr 7 '16 at 13:27













                  • I have just tried but still not working.

                    – Asad
                    Apr 7 '16 at 13:38











                  • Ohhh....U need that delivery report and all?

                    – Naveed Akhtar
                    Apr 7 '16 at 13:39











                  • no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                    – Asad
                    Apr 7 '16 at 13:41





















                  • I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                    – Asad
                    Apr 7 '16 at 13:19













                  • Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                    – Naveed Akhtar
                    Apr 7 '16 at 13:27













                  • I have just tried but still not working.

                    – Asad
                    Apr 7 '16 at 13:38











                  • Ohhh....U need that delivery report and all?

                    – Naveed Akhtar
                    Apr 7 '16 at 13:39











                  • no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                    – Asad
                    Apr 7 '16 at 13:41



















                  I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                  – Asad
                  Apr 7 '16 at 13:19







                  I have used already this one following that link new Handler().postDelayed(new Runnable() { public void run() { sendSMS(selectedContactNumbers.get(0),"this is a test"); } }, 1000*4);

                  – Asad
                  Apr 7 '16 at 13:19















                  Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                  – Naveed Akhtar
                  Apr 7 '16 at 13:27







                  Use smsManager.sendMultipartTextMessage(phone, null, texts, null, null);

                  – Naveed Akhtar
                  Apr 7 '16 at 13:27















                  I have just tried but still not working.

                  – Asad
                  Apr 7 '16 at 13:38





                  I have just tried but still not working.

                  – Asad
                  Apr 7 '16 at 13:38













                  Ohhh....U need that delivery report and all?

                  – Naveed Akhtar
                  Apr 7 '16 at 13:39





                  Ohhh....U need that delivery report and all?

                  – Naveed Akhtar
                  Apr 7 '16 at 13:39













                  no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                  – Asad
                  Apr 7 '16 at 13:41







                  no I don't need delivery report or anything else, I just need to send a sms simply that's it. But when i failed to send it by this two line "SmsManager sms = SmsManager.getDefault(); sms.sendTextMessage(ph, null, "testing sms", null, null);" then I tried to get the error message with the above code. After many tries i posted this question ,many try.

                  – Asad
                  Apr 7 '16 at 13:41













                  1














                  If you are using a Dual Sim Phone, please check if Preferred Sim for SMS, is IS NOT set to "Ask every time".



                  You need to set a default SIM. if you are using



                  SmsManager sms = SmsManager.getDefault();






                  share|improve this answer




























                    1














                    If you are using a Dual Sim Phone, please check if Preferred Sim for SMS, is IS NOT set to "Ask every time".



                    You need to set a default SIM. if you are using



                    SmsManager sms = SmsManager.getDefault();






                    share|improve this answer


























                      1












                      1








                      1







                      If you are using a Dual Sim Phone, please check if Preferred Sim for SMS, is IS NOT set to "Ask every time".



                      You need to set a default SIM. if you are using



                      SmsManager sms = SmsManager.getDefault();






                      share|improve this answer













                      If you are using a Dual Sim Phone, please check if Preferred Sim for SMS, is IS NOT set to "Ask every time".



                      You need to set a default SIM. if you are using



                      SmsManager sms = SmsManager.getDefault();







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jul 27 '17 at 22:28









                      user2060431user2060431

                      645




                      645























                          0














                          If your phone is dual sim than first you need to set a preferred sim for sms in your phone setting (google it) and that default sim must be contain some balance amount...the other short trick to set preferred default sim in your phone is-just turn one sim off for some time so another sim will automatically become your preferred default sim for sms :)
                          The phone number parameter in sendTextMessage() can be used in both ways i.e with country code like +919783###### or without code like 9783######. both will work






                          share|improve this answer




























                            0














                            If your phone is dual sim than first you need to set a preferred sim for sms in your phone setting (google it) and that default sim must be contain some balance amount...the other short trick to set preferred default sim in your phone is-just turn one sim off for some time so another sim will automatically become your preferred default sim for sms :)
                            The phone number parameter in sendTextMessage() can be used in both ways i.e with country code like +919783###### or without code like 9783######. both will work






                            share|improve this answer


























                              0












                              0








                              0







                              If your phone is dual sim than first you need to set a preferred sim for sms in your phone setting (google it) and that default sim must be contain some balance amount...the other short trick to set preferred default sim in your phone is-just turn one sim off for some time so another sim will automatically become your preferred default sim for sms :)
                              The phone number parameter in sendTextMessage() can be used in both ways i.e with country code like +919783###### or without code like 9783######. both will work






                              share|improve this answer













                              If your phone is dual sim than first you need to set a preferred sim for sms in your phone setting (google it) and that default sim must be contain some balance amount...the other short trick to set preferred default sim in your phone is-just turn one sim off for some time so another sim will automatically become your preferred default sim for sms :)
                              The phone number parameter in sendTextMessage() can be used in both ways i.e with country code like +919783###### or without code like 9783######. both will work







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Aug 8 '18 at 17:47









                              jags chaudharyjags chaudhary

                              1




                              1























                                  0














                                  Your message might be too long. In that case, you should use divideMessage and sendMultipartTextMessage, like this:



                                  smsManager.sendMultipartTextMessage(phoneNumber, null, divideMessage(message), null, null);





                                  share|improve this answer




























                                    0














                                    Your message might be too long. In that case, you should use divideMessage and sendMultipartTextMessage, like this:



                                    smsManager.sendMultipartTextMessage(phoneNumber, null, divideMessage(message), null, null);





                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      Your message might be too long. In that case, you should use divideMessage and sendMultipartTextMessage, like this:



                                      smsManager.sendMultipartTextMessage(phoneNumber, null, divideMessage(message), null, null);





                                      share|improve this answer













                                      Your message might be too long. In that case, you should use divideMessage and sendMultipartTextMessage, like this:



                                      smsManager.sendMultipartTextMessage(phoneNumber, null, divideMessage(message), null, null);






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 13 '18 at 16:37









                                      FlimmFlimm

                                      51.5k23134156




                                      51.5k23134156






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Stack Overflow!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36477226%2fsending-sms-error-generic-failure-again-and-agian%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          List item for chat from Array inside array React Native

                                          Thiostrepton

                                          Caerphilly