Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Send Multiple sms

Send Multiple sms

Scheduled Pinned Locked Moved Mobile
question
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MsmVc
    wrote on last edited by
    #1

    Hi Experts How can i send multiple(different number) SMS through code? Code is here..

    public class sms extends Activity {
    private static final String View = null;
    /** Called when the activity is first created. */
    boolean b;

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {

         sendSMS(Numbert, Message);
         Toast.makeText(sms.this, "SMS Sent", Toast.LENGTH\_LONG).show();
         
    
      } catch (Exception e) {
         
         //Toast.makeText(sms.this, e.getMessage(),Toast.LENGTH\_LONG).show();
      }
    

    }

    public void sendSMS(String number, String msg) throws Exception {
    {
    for(int i=0;i<10;i++)
    {
    SmsManager sms = SmsManager.getDefault();
    TelephonyManager telemngr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

                sms.sendTextMessage("01234555", null, "Test Message", null, null);
    

    }
    }

    P D 2 Replies Last reply
    0
    • M MsmVc

      Hi Experts How can i send multiple(different number) SMS through code? Code is here..

      public class sms extends Activity {
      private static final String View = null;
      /** Called when the activity is first created. */
      boolean b;

      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      try {

           sendSMS(Numbert, Message);
           Toast.makeText(sms.this, "SMS Sent", Toast.LENGTH\_LONG).show();
           
      
        } catch (Exception e) {
           
           //Toast.makeText(sms.this, e.getMessage(),Toast.LENGTH\_LONG).show();
        }
      

      }

      public void sendSMS(String number, String msg) throws Exception {
      {
      for(int i=0;i<10;i++)
      {
      SmsManager sms = SmsManager.getDefault();
      TelephonyManager telemngr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

                  sms.sendTextMessage("01234555", null, "Test Message", null, null);
      

      }
      }

      P Offline
      P Offline
      PavanPareta
      wrote on last edited by
      #2

      What exactly you want.. you code already seen good, are you getting any error? :~

      Pavan Pareta

      M 1 Reply Last reply
      0
      • P PavanPareta

        What exactly you want.. you code already seen good, are you getting any error? :~

        Pavan Pareta

        M Offline
        M Offline
        MsmVc
        wrote on last edited by
        #3

        Thanks for reply No i am not getting any error. But when i send message on more than one number,then some time code fail.I mean message not send successfully. So my question is that if my code is good then 1) Why not send successfully 100% 2) Or Any other option to send multiple sms

        1 Reply Last reply
        0
        • M MsmVc

          Hi Experts How can i send multiple(different number) SMS through code? Code is here..

          public class sms extends Activity {
          private static final String View = null;
          /** Called when the activity is first created. */
          boolean b;

          public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          try {

               sendSMS(Numbert, Message);
               Toast.makeText(sms.this, "SMS Sent", Toast.LENGTH\_LONG).show();
               
          
            } catch (Exception e) {
               
               //Toast.makeText(sms.this, e.getMessage(),Toast.LENGTH\_LONG).show();
            }
          

          }

          public void sendSMS(String number, String msg) throws Exception {
          {
          for(int i=0;i<10;i++)
          {
          SmsManager sms = SmsManager.getDefault();
          TelephonyManager telemngr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);

                      sms.sendTextMessage("01234555", null, "Test Message", null, null);
          

          }
          }

          D Offline
          D Offline
          Deflinek
          wrote on last edited by
          #4

          Are you sure you want to create SmsManager and TelephonyManager objects inside loop? Also, is it for android? If so, you can try to use sentIntent to check if sending was successfull or reason of failure for your messages.

          -- "My software never has bugs. It just develops random features."

          M 1 Reply Last reply
          0
          • D Deflinek

            Are you sure you want to create SmsManager and TelephonyManager objects inside loop? Also, is it for android? If so, you can try to use sentIntent to check if sending was successfull or reason of failure for your messages.

            -- "My software never has bugs. It just develops random features."

            M Offline
            M Offline
            MsmVc
            wrote on last edited by
            #5

            thanks for reply It doesn't matter for where i create SmsManager and TelephonyManager.I wont only one thing send sms 100% successfully from my side. If you have any idea then please give me tips or example Thanks in advance

            J 1 Reply Last reply
            0
            • M MsmVc

              thanks for reply It doesn't matter for where i create SmsManager and TelephonyManager.I wont only one thing send sms 100% successfully from my side. If you have any idea then please give me tips or example Thanks in advance

              J Offline
              J Offline
              JudyL_MD
              wrote on last edited by
              #6

              MsmVc wrote:

              one thing send sms 100% successfully from my side.

              If you mean one single function call that will always work, then you can't do it. Using cellular communications inherently contains the possibility of failure due to glitches in signal strength, visibility of nodes, interference, ... The best you can do is put a reasonable number of retries in your code to handle the failure case. Judy

              Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

              M 2 Replies Last reply
              0
              • J JudyL_MD

                MsmVc wrote:

                one thing send sms 100% successfully from my side.

                If you mean one single function call that will always work, then you can't do it. Using cellular communications inherently contains the possibility of failure due to glitches in signal strength, visibility of nodes, interference, ... The best you can do is put a reasonable number of retries in your code to handle the failure case. Judy

                Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

                M Offline
                M Offline
                MsmVc
                wrote on last edited by
                #7

                Thanks for valuable response Can you give me some example code? Please help me

                1 Reply Last reply
                0
                • J JudyL_MD

                  MsmVc wrote:

                  one thing send sms 100% successfully from my side.

                  If you mean one single function call that will always work, then you can't do it. Using cellular communications inherently contains the possibility of failure due to glitches in signal strength, visibility of nodes, interference, ... The best you can do is put a reasonable number of retries in your code to handle the failure case. Judy

                  Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

                  M Offline
                  M Offline
                  MsmVc
                  wrote on last edited by
                  #8

                  please help me somebody...

                  J 1 Reply Last reply
                  0
                  • M MsmVc

                    please help me somebody...

                    J Offline
                    J Offline
                    JudyL_MD
                    wrote on last edited by
                    #9

                    use my previous suggestion to add some retries ... you had code in your very first post - simply check the return value and retry if it returns an error Judy

                    Be wary of strong drink. It can make you shoot at tax collectors - and miss. Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups