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. nice example 2 uderstand
View Tutorial          By: nilesh doshi at 2011-05-09 01:24:24

2. /
//BSIT
//
#include<iost

View Tutorial          By: Joshua Torres at 2012-10-05 16:59:17

3. Very good example with explaination and sample cod
View Tutorial          By: plenitude at 2010-04-15 23:55:02

4. Class TypeCasting
{
public static v

View Tutorial          By: kishoree koli at 2013-03-14 03:00:31

5. Very nice introduction to j2me well you should als
View Tutorial          By: Bikashjit at 2012-08-29 08:53:28

6. sir i want this following pattern using loops

View Tutorial          By: teju at 2015-09-13 22:46:58

7. <%!
DateFormat date = DateFormat.getDat

View Tutorial          By: saifuctg at 2011-12-30 22:24:54

8. i want to more explanation about serlization
View Tutorial          By: sumathi at 2013-12-22 15:00:20

9. Very precisely and simply explained.
View Tutorial          By: Deepak at 2015-01-05 08:37:01

10. nice
View Tutorial          By: narendra at 2012-04-23 09:40:00