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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. its very good , good example for beginners
View Tutorial By: Rohit Mumbai at 2012-02-03 06:59:13
2. as in property we set the value and then retrieve
View Tutorial By: Deep at 2011-03-18 21:00:54
3. thanks man!u r lifesaver!!!!!!!
View Tutorial By: sneha at 2009-03-17 23:56:40
4. how to import myownclass into another class same p
View Tutorial By: rana at 2013-04-19 17:32:08
5. Dear Sir,
This code is so good. but
View Tutorial By: Jai Singh Saini at 2010-05-06 06:13:45
6. Thanks guys,
its working perfectly.
View Tutorial By: Ajmal at 2015-03-25 08:30:07
7. the thirst of knowledge getting quenched..
View Tutorial By: Mohnish Vidyarthi at 2013-10-04 18:12:29
8. thanx allot its a very good sample , but im trying
View Tutorial By: Waleed Qaffaf at 2011-06-09 09:37:15
9. Cant undrstand clearly
View Tutorial By: rathika at 2014-06-09 11:02:16
10. Respected sir,
I am trying to embed windows
View Tutorial By: arshad at 2011-10-22 17:05:21