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. //Program of Method Overloading with Runtime Value
View Tutorial          By: Subhojit Das at 2014-10-09 07:31:20

2. Hi Blackpanther, the mode is either 0 or 1. If you
View Tutorial          By: Ramlak at 2008-04-01 02:24:14

3. it's cool
but on other way it is indeed har

View Tutorial          By: johncarlo at 2009-02-05 04:44:13

4. is there a way to notify a specific thread?
View Tutorial          By: bob at 2010-03-23 11:57:29

5. Also note that for reverse ordering, If you have a
View Tutorial          By: Dwight at 2011-07-13 22:13:45

6. Just read the first page, It really attractive. Le
View Tutorial          By: Md. Sumon Bappi at 2015-05-13 10:47:00

7. can u tell me mobile tracker code in j2me
w

View Tutorial          By: aiyaz at 2010-08-21 16:29:08

8. I did all steps, but it only shows the first pictu
View Tutorial          By: behzad at 2012-07-15 16:32:41

9. This is first time i am using this net
View Tutorial          By: selvam at 2008-08-19 00:04:44

10. not good example to learn the overriding methods
View Tutorial          By: george at 2010-04-25 12:08:20