Hi....Experts
I'm Woking on Auto Sending Sms can any send me the code form that.....
Hi....Experts
I'm Woking on Auto Sending Sms can any send me the code form that.....
Auto send? Are you talking about the fact that the MIDlet asks for permission to send SMS messages (getting rid of the confirmations requires signing which requires you to buy a certificate and even that does not guarantee that you get rid of the confirmations as on some phones the confirmations will be always there). For more information see for example here http://wiki.forum.nokia.com/index.ph...curity_Domains
If you are just looking for code samples for sending SMS messages see here http://wiki.forum.nokia.com/index.ph...aging_Articles
Hartti
if I gave the date and time sms Should go on that time...
now i did that the problem is that that application should be running till the sms to go... if exit sms wont go...
However keep in mind that you need to provide the permission to the app at the time of the invocation of the application using the push registry. This permission even will asked if the app is signed using the third party certificate.
Thanks with Regards,
R a j - The K e r n e l
Join Delhi-NCR Nokia Developer's Community,
For more clearance,
Your application would register for push registry with alarm of specific date and time. and your applications sms sender module should always become active on app start, if the system time reach the specified time, than it will initiate the sms sending task.
If the application is closed than alarm will push start your application and your sms sender module will send the defined sms, followed by permission querry.
- Mekal
This is my code plz help me....class name is Alarm.. plz fix the problem
import java.io.IOException;
import java.util.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.io.Connector;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;
public class Alarm extends MIDlet implements ItemStateListener,CommandListener {
private Alert alert;
private String port;
private Display display;
private Form fmMain;
private Command cmAlarm;
private Command cmReset;
private Command cmExit;
private DateField dfAlarmTime;
private TextField desc,number;
private int dateIndex;
private Date currentTime;
private Timer tm;
private AlarmTimer tt;
private boolean dateOK = false;
public Alarm() {
display = Display.getDisplay(this);
port = "50055";
if(getAppProperty("Port-SMS") != null)
port = getAppProperty("Port-SMS");
alert = new Alert(null);
alert.setTimeout(3000);
fmMain = new Form("When to Send SMS:");
currentTime = new Date();
dfAlarmTime = new DateField("", DateField.DATE_TIME);
dfAlarmTime.setDate(currentTime);
cmAlarm = new Command("Sleep", Command.SCREEN, 1);
cmReset = new Command("Reset", Command.SCREEN, 1);
cmExit = new Command("Exit", Command.EXIT, 1);
desc = new TextField("Description", "", 20, TextField.ANY);
number = new TextField("Number", "", 20, TextField.PHONENUMBER);
dateIndex = fmMain.append(dfAlarmTime);
fmMain.addCommand(cmAlarm);
fmMain.addCommand(cmReset);
fmMain.addCommand(cmExit);
fmMain.append(desc);
fmMain.append(number);
fmMain.setCommandListener(this);
fmMain.setItemStateListener(this);
}
public void startApp() {
display.setCurrent(fmMain);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void itemStateChanged(Item item) {
if (item == dfAlarmTime) {
if (dfAlarmTime.getDate().getTime() < currentTime.getTime())
dateOK = false;
else
dateOK = true;
}
}
public void commandAction(Command c, Displayable s) {
if (c == cmAlarm) {
if (dateOK == false) {
Alert al = new Alert("Unable to set alarm",
"Please choose another date and time.", null, null);
al.setTimeout(Alert.FOREVER);
al.setType(AlertType.ERROR);
display.setCurrent(al);
}
else {
tm = new Timer();
tt = new AlarmTimer();
long amount = dfAlarmTime.getDate().getTime() -
currentTime.getTime();
tm.schedule(tt,amount);
fmMain.removeCommand(cmAlarm);
fmMain.removeCommand(cmReset);
fmMain.delete(dateIndex);
fmMain.deleteAll();
fmMain.setTitle("Sleeping...");
}
} else if (c == cmReset) {
dfAlarmTime.setDate(currentTime = new Date());
} else if (c == cmExit) {
destroyApp(false);
notifyDestroyed();
}
}
private class AlarmTimer extends TimerTask {
public final void run() {
Alert al = new Alert("");
al.setTimeout(Alert.FOREVER);
AlertType.CONFIRMATION.playSound(display);
MessageConnection conn = null;
String address= "sms://" + number.getString();
try {
conn = (MessageConnection) Connector.open(address);
TextMessage msg = (TextMessage)
conn.newMessage(MessageConnection.TEXT_MESSAGE);
msg.setAddress(address);
msg.setPayloadText( desc.getString());
conn.send(msg);
alert.setString("Sending to " +address.substring(6));
alert.setType(AlertType.INFO);
display.setCurrent(alert);
} catch (IOException ioe) {
ioe.printStackTrace();
}
if (conn != null) {
try {
conn.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
cancel();
}
}
}
Last edited by Dushyanth; 2011-04-14 at 20:25.
if I gave the date and time sms Should go on that specified time...
i did that ... but the problem is ., that application should be running till the sms is sent....
and if i exit the application sms wont go....