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. very good for programing
View Tutorial          By: kiran at 2007-12-06 00:39:47

2. Nice post. I am learning so much things from your
View Tutorial          By: Umesh Kumar at 2012-03-15 11:16:24

3. i tried your code but i got an error on this line<
View Tutorial          By: edward at 2011-12-09 11:32:30

4. can i add new language for my freetts project ? I'
View Tutorial          By: [email protected] at 2011-08-09 06:49:52

5. good info to create package
View Tutorial          By: Nirdesh at 2012-10-01 03:45:02

6. super j2me introduction
View Tutorial          By: govinth at 2012-02-05 09:33:18

7. i want to sending sms code in java. send me that c
View Tutorial          By: Montu at 2011-06-01 15:15:56

8. I have a sample code in which,

obje

View Tutorial          By: Tan Mi at 2011-10-25 23:24:10

9. Nice site to assist learners to study without much
View Tutorial          By: Hot.g at 2009-12-01 02:36:02

10. Hi Jon,

It really depends on the ap

View Tutorial          By: Hong at 2009-05-04 20:40:28