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. Exception in thread "main" java.lang.NoC
View Tutorial          By: RobustTm at 2008-12-18 23:19:46

2. hi, ashray p shetty
can you please tell me

View Tutorial          By: amrish at 2010-12-12 07:30:49

3. Don't you just love people who all assume we use w
View Tutorial          By: Alan at 2012-08-01 09:10:26

4. how do one off the alarm after it has triggered th
View Tutorial          By: Asika at 2009-10-01 07:28:50

5. Hello,

Is there anyway the datagrid

View Tutorial          By: Douglas at 2010-05-13 22:10:09

6. very nice explanation of STATIC....HAY man , you j
View Tutorial          By: harkeet at 2012-12-18 17:48:43

7. Your page does not show the text in the proper col
View Tutorial          By: Warron at 2013-04-04 17:50:22

8. Hi,

I can use this programme to sen

View Tutorial          By: malak at 2012-11-25 17:21:00

9. Thanks a ton! :)
View Tutorial          By: Prateek at 2015-03-12 11:40:08

10. need to be explained more
View Tutorial          By: parul at 2011-06-30 08:34:29