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, my name is Jaime,
I wan't to do a jsp w

View Tutorial          By: Jaime at 2011-10-24 12:47:50

2. I need one help how to update particular column da
View Tutorial          By: santhosh.s at 2015-01-22 15:09:33

3. Very good explanation along with the example. Can
View Tutorial          By: Divya at 2010-09-21 03:05:10

4. It is the same as #include
View Tutorial          By: Ballu at 2011-07-04 06:42:55

5. Thank you
View Tutorial          By: vbulletincoder at 2011-09-13 13:16:40

6. I want inserted switch statement in my program,
View Tutorial          By: shah at 2011-02-07 01:11:12

7. Yesu. Thenk a u vely muchos. HURRRRR
View Tutorial          By: hurr durr at 2013-09-19 19:50:23

8. That was very nice yaar.
View Tutorial          By: sana at 2014-02-21 09:20:34

9. Hi , it was nice tutorial to understand the differ
View Tutorial          By: jagan at 2014-06-05 05:13:59

10. can i get some basic examples of java program
View Tutorial          By: raja at 2013-06-04 10:47:12