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. i want daily tutorials
View Tutorial          By: ashish at 2007-12-18 04:26:19

2. if(isset($_POST["check1"]=="1"
View Tutorial          By: krunal at 2012-11-22 10:30:19

3. i want to know about basic requirement for jdbc ,
View Tutorial          By: Amit sharma at 2009-03-19 04:10:24

4. Hello sir pls send me
com.sun.speech.freett

View Tutorial          By: shanthi at 2013-03-22 11:18:56

5. I have loaded allthe 5 java files.But how to imple
View Tutorial          By: ashish at 2007-03-08 20:33:11

6. constructors are not to be called. when you make a
View Tutorial          By: niyati at 2011-05-28 07:57:52

7. short and simple program
hel

View Tutorial          By: sourabh agrawal at 2012-10-16 04:55:27

8. too good post....very easy to understand
View Tutorial          By: Rahul at 2013-03-04 17:09:58

9. how to show text in tab menu & when i selecte
View Tutorial          By: hina siddiqui at 2011-08-09 07:38:14

10. how to display image on gridview from mysql databa
View Tutorial          By: chirag at 2013-03-18 08:12:46