Sending SMS to multiple recipients

Put your problem here if it does not fit any of the other categories.

Sending SMS to multiple recipients

Postby dinho256 » Fri Mar 11, 2011 2:16 pm

Hi,

I developed an app wich allows the SMS sending. It works fine and I used a tutorial I've read on the Web.

But that app only allows me to send the SMS for one single number! I tried to separe with comma and still not working. Does anybody knows how to fix that?

Here's the part of the code that sends the SMS

Code: Select all
    btn_enviar.setOnClickListener(new View.OnClickListener()
        {      
         @Override
         public void onClick(View v) {
            String numero = et_numeros.getText().toString();
            String mensagem = et_mensagem.getText().toString();

            if(numero.length()>0 && mensagem.length()>0)
               {
            sendSMS(numero,mensagem);
            Toast.makeText(getBaseContext(), "Tentando enviar seu SMS para " + numero, Toast.LENGTH_SHORT).show();   
               }
            else
            {
               Toast.makeText(getBaseContext(), "Você deve digitar um número válido e um texto para enviar um SMS!", Toast.LENGTH_SHORT).show();
            } }
         
      });


As you can see, it picks the number from the Object "numero" which is and EditText I created on the XML and the "mensagem" is another one that contains the message, then the app checks if they're not empty and only then it sends the message.

Should I create an Array or maybe connect into a database and use a For to send the SMS? Because I have lots of numbers to send the message. What's the better way for doing that?

Thanks ! :)
dinho256
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 03, 2011 7:14 pm

Top

Re: Sending SMS to multiple recipients

Postby dinho256 » Fri Mar 11, 2011 3:02 pm

Heheeey! Just solved that!!

I had to create a FOR to run the whole Array, going position by position!!

Here's the chages, just for sharing! =)

Code: Select all
       btn_enviar.setOnClickListener(new View.OnClickListener()
        {      
         @Override
         public void onClick(View v) {
            for (int i = 0; i < numeros.length; i++) {

            String numero = numeros[i];//et_numeros.getText().toString();
            String mensagem = et_mensagem.getText().toString();
      
               
            if(numero.length()>0 && mensagem.length()>0)
               {
            sendSMS(numero,mensagem);
            Toast.makeText(getBaseContext(), "Tentando enviar seu SMS para " + numero, Toast.LENGTH_SHORT).show();   
               }
            else
            {
               Toast.makeText(getBaseContext(), "Você deve digitar um número válido e um texto para enviar um SMS!", Toast.LENGTH_SHORT).show();
            }
         }
         }
      });



But I'm now wondering if it's possible to load the Array from a database or a text file? Does anybody knows that?

Thanks! =D
dinho256
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 03, 2011 7:14 pm

Re: Sending SMS to multiple recipients

Postby dinho256 » Fri Mar 11, 2011 9:26 pm

Oke, i really got that working with the Array, but does anybody knows how to load the content of a txt file located at sdcard into the array?

Pleeeease help!! :\

Thanks!
dinho256
Freshman
Freshman
 
Posts: 3
Joined: Thu Feb 03, 2011 7:14 pm

Re: Sending SMS to multiple recipients

Postby raj_J2ME » Mon Mar 14, 2011 8:09 am

dinho256 wrote:Oke, i really got that working with the Array, but does anybody knows how to load the content of a txt file located at sdcard into the array?

Pleeeease help!! :\

Thanks!

Yeah you can read the data from either of them. You can read the Data, from the data base or you can use file system to read the same.
To read the data from the File System, please follow the link,
http://www.anddev.org/read_a_txt_file_from_sd_card_in_a_real_device-t6619.html

and in order to read the data from the databse you can go through the link,
http://www.giantflyingsaucer.com/blog/?p=1342

Please check if this stuff helps you,
Thanks with Regards,
Raj - The Kernel
raj_J2ME
Master Developer
Master Developer
 
Posts: 311
Joined: Tue Feb 15, 2011 7:40 am
Location: The Capital of India,

Re: Sending SMS to multiple recipients

Postby andbois » Tue Mar 15, 2011 10:30 am

That would be a big help for beginner like me. I hope someday you can help me with my problems soon. Keep it up guys.
andbois
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Mar 10, 2011 2:05 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 18 guests