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 sms multiple recipients

Send sms multiple recipients

Scheduled Pinned Locked Moved Mobile
help
17 Posts 4 Posters 3 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 MsmVc

    Thanks for reply

    SmsManager sms = SmsManager.getDefault();

    I found article from http://mobiforge.com/developing/story/sms-messaging-android[^] I haven't ask question from author. If you know then please help me

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #4

    MsmVc wrote:

    I haven't ask question from author.

    Now would be a good time. Taking a look at SmsManager.sendTextMessage()[^] it would appear that it only accepts a single phone number in the first parameter (but I may be wrong); I would suggest you check that your syntax is valid for SMS.

    I must get a clever new signature for 2011.

    M 1 Reply Last reply
    0
    • L Lost User

      MsmVc wrote:

      I haven't ask question from author.

      Now would be a good time. Taking a look at SmsManager.sendTextMessage()[^] it would appear that it only accepts a single phone number in the first parameter (but I may be wrong); I would suggest you check that your syntax is valid for SMS.

      I must get a clever new signature for 2011.

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

      yes sir i try to send like this

      sms.sendTextMessage("609,606,", null, message, null, null);

      But result is only first number got SMS rest is skip. Please help me

      L 1 Reply Last reply
      0
      • M MsmVc

        yes sir i try to send like this

        sms.sendTextMessage("609,606,", null, message, null, null);

        But result is only first number got SMS rest is skip. Please help me

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #6

        Did you read my previous message? Did you check the syntax of the sendTextMessage() command in the link I gave you?

        I must get a clever new signature for 2011.

        M 1 Reply Last reply
        0
        • M MsmVc

          Hi All I am trying to send SMS through program.I am able to send text SMS on Single recipient(only one number) at a time but i try to send SMS more than one number.Then i have found some article,i read that article and implement it.But it's not working for me.

          ArrayList<String> myArr = new ArrayList<String>();

                myArr.add("557");
                myArr.add("12178");
          

          StringBuilder sb = new StringBuilder();
          for (String string : myArr) {
          sb.append(string);
          sb.append(";");
          }
          sm.sendTextMessage(sb.toString(), null, message, null, null);

          Please help me

          P Offline
          P Offline
          parths
          wrote on last edited by
          #7

          Is there a specific reason why you have not put the sendTextMessage inside the loop?

          for (String string : myArr) {
          sm.sendTextMessage(string, null, message, null, null);
          }

          Of course it would be advisable to implement the send and delivered intents.

          "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

          L M 2 Replies Last reply
          0
          • P parths

            Is there a specific reason why you have not put the sendTextMessage inside the loop?

            for (String string : myArr) {
            sm.sendTextMessage(string, null, message, null, null);
            }

            Of course it would be advisable to implement the send and delivered intents.

            "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #8

            The array contains a list of numbers, not messages. He is trying to send a single message to multiple numbers.

            I must get a clever new signature for 2011.

            P 1 Reply Last reply
            0
            • P parths

              Is there a specific reason why you have not put the sendTextMessage inside the loop?

              for (String string : myArr) {
              sm.sendTextMessage(string, null, message, null, null);
              }

              Of course it would be advisable to implement the send and delivered intents.

              "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

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

              Thanks for reply but result is same,one first number got sms. Really i stuck here,now i need some extra ordinary tips or example to solve that problem. Please help me

              P 1 Reply Last reply
              0
              • L Lost User

                Did you read my previous message? Did you check the syntax of the sendTextMessage() command in the link I gave you?

                I must get a clever new signature for 2011.

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

                yes sir i read and check.Destination number type is string and i try to put there array values. Sir please help me

                L 1 Reply Last reply
                0
                • L Lost User

                  The array contains a list of numbers, not messages. He is trying to send a single message to multiple numbers.

                  I must get a clever new signature for 2011.

                  P Offline
                  P Offline
                  parths
                  wrote on last edited by
                  #11

                  Right, and he was trying to concatenate the numbers into a delimited string and call the function once, I suggested, that instead of calling the sendTextMessage function once with a delimited string of numbers, he could try calling the function multiple times with each of the numbers. Anyways, it seems it isn't working for him. I'll try it out myself and see if I can figure why not.

                  "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

                  L 1 Reply Last reply
                  0
                  • M MsmVc

                    Thanks for reply but result is same,one first number got sms. Really i stuck here,now i need some extra ordinary tips or example to solve that problem. Please help me

                    P Offline
                    P Offline
                    parths
                    wrote on last edited by
                    #12

                    Well, this worked for me.

                    package com.partho.smstomany;

                    import android.app.Activity;
                    import android.os.Bundle;

                    import android.content.Intent;
                    import android.net.Uri;

                    import java.util.StringTokenizer;
                    import android.app.PendingIntent;
                    import android.telephony.SmsManager;

                    public class pSMSToMany extends Activity
                    {
                    /** Called when the activity is first created. */
                    @Override
                    public void onCreate(Bundle savedInstanceState)
                    {
                    super.onCreate(savedInstanceState);
                    setContentView(R.layout.main);

                    	String message = "Some Message";
                        String phoneNo = "5556;5558";
                    	
                    	StringTokenizer st=new StringTokenizer(phoneNo,";");
                    	while (st.hasMoreElements())
                    	{
                    		String tempMobileNumber = (String)st.nextElement();
                    		if(tempMobileNumber.length()>0 && message.trim().length()>0) {
                    			SmsManager sms = SmsManager.getDefault();
                    			sms.sendTextMessage(tempMobileNumber, null, message, null, null);    
                    		}
                    	}
                    }
                    

                    }

                    Actual code from Here[^]. Dumbed down to try it out.

                    "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

                    1 Reply Last reply
                    0
                    • M MsmVc

                      yes sir i read and check.Destination number type is string and i try to put there array values. Sir please help me

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #13

                      MsmVc wrote:

                      i try to put there array values.

                      Yes but you are only allowed to put a single number in that field as I pointed out before. Try reading through the documentation more carefully.

                      I must get a clever new signature for 2011.

                      N 1 Reply Last reply
                      0
                      • P parths

                        Right, and he was trying to concatenate the numbers into a delimited string and call the function once, I suggested, that instead of calling the sendTextMessage function once with a delimited string of numbers, he could try calling the function multiple times with each of the numbers. Anyways, it seems it isn't working for him. I'll try it out myself and see if I can figure why not.

                        "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #14

                        My apologies, I totally mis-read that line; I suspect my brain was powered off. :(

                        I must get a clever new signature for 2011.

                        P 1 Reply Last reply
                        0
                        • L Lost User

                          My apologies, I totally mis-read that line; I suspect my brain was powered off. :(

                          I must get a clever new signature for 2011.

                          P Offline
                          P Offline
                          parths
                          wrote on last edited by
                          #15

                          Richard MacCutchan wrote:

                          my brain was powered off.

                          No Problem, I've been there too often :) I have posted below, some code that worked on my emulators and another forum link that suggested the solution.

                          "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

                          1 Reply Last reply
                          0
                          • L Lost User

                            MsmVc wrote:

                            i try to put there array values.

                            Yes but you are only allowed to put a single number in that field as I pointed out before. Try reading through the documentation more carefully.

                            I must get a clever new signature for 2011.

                            N Offline
                            N Offline
                            n3rd702z
                            wrote on last edited by
                            #16

                            Use a loop and an array list -.- ArrayList pNumbers = new ArrayList(); pNumbers.Add("6194442221"); pNumbers.Add("6194442222"); pNumbers.Add("6194442223"); pNumbers.Add("6194442224"); for(int i = 0; i < pNumbers.Count - 1; i++) { sms.sendTextMessage(pNumbers[i], null, message, null, null); }

                            L 1 Reply Last reply
                            0
                            • N n3rd702z

                              Use a loop and an array list -.- ArrayList pNumbers = new ArrayList(); pNumbers.Add("6194442221"); pNumbers.Add("6194442222"); pNumbers.Add("6194442223"); pNumbers.Add("6194442224"); for(int i = 0; i < pNumbers.Count - 1; i++) { sms.sendTextMessage(pNumbers[i], null, message, null, null); }

                              L Offline
                              L Offline
                              Lost User
                              wrote on last edited by
                              #17

                              Isn't this what was proposed weeks ago?

                              I must get a clever new signature for 2011.

                              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