Comment on Tutorial - How to Send SMS using Java Program (full code sample included) By Emiley J.



Comment Added by : pradeep

Comment Added at : 2012-01-25 06:30:14

Comment on Tutorial : How to Send SMS using Java Program (full code sample included) By Emiley J.
hi ..........
the code is worked for me..... thank our author a lot...
those who are having timeout problem, pls follow the sender.java code:
import java.util.Date;


public class Sender implements Runnable {


SerialConnection mySerial =null;


static final private char cntrlZ=(char)26;

String in, out;

Thread aThread=null;

String recipient=null;

String message=null;


private String csca="+919840011003"; // the message center

private SerialParameters defaultParameters= new SerialParameters ("COM14",460800,0,0,8,1,0);

public Sender(String recipient, String message){


this.recipient=recipient;

this.message=message;


}

/**
* connect to the port and start the dialogue thread
*/

public int send () throws Exception{


SerialParameters params = defaultParameters;


mySerial =new SerialConnection (params);


mySerial.openConnection();


aThread=new Thread(this);


aThread.start() ;

return 0;

}


/**
* implement the dialogue thread,
* message / response via steps,
* handle time out
*/


public void run(){


try{


int expectedResult=-1;


mySerial.send("at");

System.out.println("...............");

mySerial.send("at+cmgf=1");

mySerial.send("at+csca=\""+csca+"\"");

System.out.println("++++++++++");
mySerial.send("at+cmgs=\""+recipient+"\"");

System.out.println("***********");
System.out.println("***********");
mySerial.send(message+cntrlZ);

}
catch (Exception e){

e.printStackTrace();

}

}

}



Also change in SMSCLient.java..........remove the mode ,SYNC , ASYNC ,status and all........ surely u ll get output.. thanks


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Your example is clear crisp and very helpful..
View Tutorial          By: sridhar at 2009-08-06 08:41:14

2. Thanks
muchas gracias
Excellent

View Tutorial          By: Alfredo at 2010-05-31 09:00:36

3. thank's a lot for giving me " static "
View Tutorial          By: anwar kotawdekar at 2013-08-14 06:43:34

4. i am looking for c programs in written
View Tutorial          By: ziyauddin at 2011-02-13 06:21:09

5. Hi its good for the learners and thosse who forgot
View Tutorial          By: Md.Abdul Gaffar at 2008-01-12 06:00:14

6. Nothing that hasn't been said before, but I wasn't
View Tutorial          By: Calvin at 2010-03-22 20:43:10

7. Nice article .... Thank you...
View Tutorial          By: viswa at 2012-06-16 17:21:59

8. someone explain how to use PreparedStatements with
View Tutorial          By: Manikprabhu at 2011-03-26 00:04:54

9. Its awesome
View Tutorial          By: Ranjitha at 2012-08-02 10:21:59

10. Really clear and lucid explanation abt realloc ...
View Tutorial          By: metarus208 at 2012-01-01 14:25:25