Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2009

    Sending SMS...??

    I have developed an application which captures two frames and compares whether any motion is detected or not …as when motion is detected, my application should send an SMS to the specified Number automatically when motion is detected….

    So I have downloaded a code “ Sending a txt message ” from forums.. but when I run that code it is asking for NUMBER and MESSAGE to be typed in text field….

    I want to give the “ Number: 9966616186 and Message: Motion Detected “ in the application itself……when the motion is detected automatically the message should be sent to the given number…. In my application where should I specify the “Number and Message “.

    Please sir its very urgent….tommorrow I have a demo please help me sir…

    MY “sending a txt message” code: ( in this code where should I place Number and Message)

    import java.io.IOException;
    import java.io.InterruptedIOException;
    import javax.microedition.io.Connector;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.MIDlet;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;
    public class SMSMidlet extends MIDlet implements CommandListener {
        private Command sendCommand;
        private Command exitCommand;
        private Form mainForm;
        private TextField smsNumber;
        private TextField smsText;
        private MessageConnection connection;
        public SMSMidlet() {
            mainForm = new Form("");
            smsNumber = new TextField("Phone number", null, 20,TextField.PHONENUMBER);
            smsText = new TextField("Text", null, 160, TextField.ANY);
            sendCommand = new Command("Send", Command.ITEM, 0);
            exitCommand = new Command("Exit", Command.EXIT, 0);
        public void startApp() {
        public void pauseApp() {
        public void destroyApp(boolean unconditional) {
            if (connection != null) {
                try {
                } catch (IOException ex) {
        public void commandAction(Command command, Displayable displayable) {
            if (command == exitCommand) {
            } else if (command == sendCommand) {
        private void send() {
            try {
                connection = (MessageConnection)Connector.open("sms://");
            } catch (IOException ex) {
            TextMessage message = prepareSMS();
        private TextMessage prepareSMS() {
            TextMessage message = (TextMessage)connection.newMessage(MessageConnection.TEXT_MESSAGE);
            String number = "sms://" + smsNumber.getString();
            String text = smsText.getString();
            return message;
        private void sendSMS(final TextMessage message) {
            Thread smsThread = new Thread() {
                public void run() {
                    try {
                        mainForm.append("Message sent.");
                    } catch (InterruptedIOException ex) {
                    } catch (IOException ex) {
                    } catch (IllegalArgumentException ex) {
                    } catch (SecurityException ex) {
    /////////////////////please modify this code and resend sir please////////////////////
    Last edited by kiran10182; 2010-02-19 at 09:41. Reason: Wrapping up with [code] tags for better readability

  2. #2
    Regular Contributor
    Join Date
    Feb 2010

    Re: Sending SMS...??


    refer following
    messag.setAddress() is used to set Number alsong with sms:// protocol
    message.setPayloadText is used to set the message content.

    private TextMessage prepareSMS() {
    TextMessage message = (TextMessage)connection.newMessage(MessageConnection.TEXT_MESSAGE);
    String number = "sms://" +"9966616186"; 
    message.setPayloadText("Motion Detected");
    return message;

    You should read API docs first before raising any question...


Similar Threads

  1. Specifying port number while sending SMS?
    By sunil_bhambani123 in forum Mobile Java Networking & Messaging & Security
    Replies: 18
    Last Post: 2009-03-24, 06:09
  2. SMS sending, Nokia S40
    By RomkaRomka in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2008-12-11, 08:50
  3. Problem in sending SMS using VB
    By sylvia in forum General Messaging
    Replies: 0
    Last Post: 2006-09-27, 07:38
  4. Problem in sending SMS
    By sylvia in forum Symbian Networking & Messaging (Closed)
    Replies: 4
    Last Post: 2006-09-27, 07:06
  5. HELP! problem w/ sending and reading sms..
    By mauve928 in forum General Messaging
    Replies: 0
    Last Post: 2003-12-14, 19:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts