Send SMS

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

Send SMS

Postby mddevc » Fri Feb 04, 2011 7:58 am

Hi Experts

How can i send multiple SMS through code? Code is here..

Code: Select all
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);
}
}

It's not working proper, only one sms send successfully. Can any one guide me what i have to do for send 10 time sms on particular number?
mddevc
Once Poster
Once Poster
 
Posts: 1
Joined: Fri Feb 04, 2011 7:45 am

Top

Re: Send SMS

Postby wakawaka » Thu Feb 10, 2011 1:09 pm

You got solution for this?
Android Development Tutorials and Code Snippets: http://forum.gssdaily.com/
wakawaka
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Tue Jan 11, 2011 1:51 pm

Re: Send SMS

Postby nlearnerandroid » Mon Feb 28, 2011 12:16 pm

No i havn't got solution.

If you have solution then plz help me
nlearnerandroid
Junior Developer
Junior Developer
 
Posts: 10
Joined: Wed Dec 29, 2010 5:58 am

Re: Send SMS

Postby raj_J2ME » Mon Feb 28, 2011 1:00 pm

mddevc wrote:Hi Experts

How can i send multiple SMS through code? Code is here..

Code: Select all
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);
}
}

It's not working proper, only one sms send successfully. Can any one guide me what i have to do for send 10 time sms on particular number?


You need to test a couple of points:

1. Was the loop called the allowed and expected number if times, out println inside the loop and check if this is running correctly,

2. Try bu changing the number of the receiver of the SMS and check if the same code can send the SMS to the other numbers.

Also this link I found very much helpful, try to put the logic of the sending the SMS inside the loop and test if this can help 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,

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests