Send sms multiple recipients
-
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
-
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
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.
-
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.
-
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.
-
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.
-
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.
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.
-
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
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.
-
yes sir i read and check.Destination number type is string and i try to put there array values. Sir please help me
-
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.
-
My apologies, I totally mis-read that line; I suspect my brain was powered off. :(
I must get a clever new signature for 2011.
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.
-
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.
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); }
-
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); }