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. Hi,

can we use only code given belo

View Tutorial          By: Mahendra at 2012-05-24 10:57:25

2. this really helps me alot :)
View Tutorial          By: liezl at 2014-08-08 13:38:58

3. i want java code for day planner please send me on
View Tutorial          By: sumaiya pathan at 2010-10-15 21:34:23

4. i want to know about simple java structure with br
View Tutorial          By: Rambahaz at 2009-09-07 06:41:25

5. It is very useful.thank you so much.
View Tutorial          By: Pratiksha ijagaj at 2010-11-27 07:03:52

6. Where is the methods related
View Tutorial          By: Osvaldo F. L. Mendes at 2008-03-17 15:40:48

7. If i run this program----



View Tutorial          By: pratham at 2010-09-22 10:10:11

8. Hi , I am mew to java please can u send detail how
View Tutorial          By: ramanji at 2011-12-11 05:36:41

9. I have a squid proxy installed as forward proxy an
View Tutorial          By: ruffy at 2012-12-20 12:34:15

10. could u help me i want to integrate the paypal sys
View Tutorial          By: Anand at 2011-01-17 21:59:25