×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Iran - Tabriz
    Posts
    111

    Update via sms ???

    Hi
    is it possible update app with sms ??? like change the text of canvas to text of sms ???
    thanks

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Update via sms ???

    Sorry to say that its not possible
    Regards,
    Saurabh

  3. #3
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Update via sms ???

    Quote Originally Posted by mahdi68 View Post
    Hi
    is it possible update app with sms ??? like change the text of canvas to text of sms ???
    thanks
    Please explain the need in much more details..

    Where the text is that you wanna replace?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,545

    Re: Update via sms ???

    If it is dynamic text/strings in the app, you can, of course, read the text from the RMS, a file, from the network, or from an SMS.

    Note, though, that a Java MIDlet cannot read any SMS, but just those sent to a specific port that the MIDlet is listening to.

  5. #5
    Regular Contributor
    Join Date
    Aug 2009
    Location
    Iran - Tabriz
    Posts
    111

    Re: Update via sms ???

    Quote Originally Posted by raj_J2ME View Post
    Please explain the need in much more details..

    Where the text is that you wanna replace?
    i make a string and save text into it and show it`s on canvas , i want change the string with sms text ;

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    9

    Re: Update via sms ???

    yes, it is possible.
    here are the general steps.
    1. you have to code your midlet to be awaken by data push. (check midlet autostart listening on a given port.)
    2. you can send an SMS to the phone on which the midlet is installed (depending on the SMS server that you're using you can specify the SMS delivery in a port different from de default, which is 0)
    This is very important because if you send an standard SMS your midlet will have to listen to port 0 and therefore it will autostart each time that an SMS comes into the phone, this is ok in most of the phones, but it will cause an overhead and you'll have to check for some specific text in the SMS as soon as you receive it for reacting to the proper ones.
    3. in the midlet startup method, you'll have to detect if the midlet was started by the user or by a data push action.(see example code below, it is a midlet for receiving SMSs on port 16555)
    4. once you isolated the text from the sms, you can use it in your canvas as any ohter string.

    good luck

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;

    import javax.wireless.messaging.*;
    import javax.microedition.io.*;

    import java.util.*;

    public class ReceiveSMS extends MIDlet implements CommandListener, MessageListener {
    Display display;
    int answerPort = 16555; //listening port, default is 0

    Form mainScreen = new Form("Status");

    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    Vector listeners = new Vector();
    boolean alreadyListening; // for knowing if we already have a thread listenign for connections..

    /** Constructor */
    public ReceiveSMS() {
    mainScreen.addCommand(exitCommand);
    mainScreen.setCommandListener(this);

    alreadyListening = false;
    String asdf = getAppProperty("PortNumber");
    if (asdf != null && !asdf.equals("") ) {
    answerPort = Integer.parseInt(asdf);
    }
    }

    /** Main method */
    public void startApp() {
    // List of active connections
    String connections[];

    // Check if any inbound connection are awayting
    connections = PushRegistry.listConnections(true); // true = only the ones with data waiting, false = all

    // if there is any inbound data
    if (connections.length != 0) {
    // We are woken up by the PushRegistry capacity.
    mainScreen.append(getStringTime() + " midlet launched by an incoming SMS\n");
    for (int i = connections.length - 1; i >= 0; i--) {
    try {
    MessageConnection mc = (MessageConnection) Connector.open(connections[i]);
    mc.setMessageListener(this);
    listeners.addElement(mc);
    }
    catch (java.lang.SecurityException exp) {
    mainScreen.append(getStringTime() + " access denied for receiving messages.. you won't be able to see the answer!!");
    }
    catch (java.io.IOException exp) {
    mainScreen.append(getStringTime() + " Error reading SMS\n");
    }
    }
    }
    else {
    connections = PushRegistry.listConnections(false);
    mainScreen.append(getStringTime() + " midlet launched by the user " +
    connections.length + " registered conections.\n");
    for (int i = connections.length - 1; i >= 0; i--) {
    try {
    MessageConnection mc = (MessageConnection) Connector.open(connections[i]);
    mc.setMessageListener(this);
    listeners.addElement(mc);
    }
    catch (java.lang.SecurityException exp) {
    mainScreen.append(getStringTime() +
    "access denied for receiving messages.. you won't be able to see the answer!!!!");
    }
    catch (java.io.IOException exp) {
    mainScreen.append(getStringTime() + " Error reading SMS\n");
    }
    }
    }
    display = Display.getDisplay(this);
    display.setCurrent(mainScreen);
    }

    /** Handle pausing the MIDlet */
    public void pauseApp() {
    notifyPaused();
    }

    /** Handle destroying the MIDlet */
    public void destroyApp(boolean unconditional) {
    if (listeners != null) {
    while (listeners.isEmpty() == false) {
    MessageConnection mc = (MessageConnection) listeners.firstElement();
    if (mc != null) {
    try {
    mc.setMessageListener(null);
    mc.close();
    }
    catch (Exception exp) {}
    }
    listeners.removeElementAt(0);
    }
    }
    notifyDestroyed();
    }

    public void commandAction(Command c, Displayable d) {
    if (c.getCommandType() == Command.EXIT) {
    destroyApp(true);
    }
    }

    protected String getStringTime() {
    Calendar calendar = Calendar.getInstance();
    Date date = new Date();
    calendar.setTime(date);
    return calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.MILLISECOND);
    }

    public void notifyIncomingMessage(MessageConnection conn) {
    try {
    TextMessage aMess = (TextMessage) conn.receive();
    mainScreen.append(getStringTime() + "MSG rcv:>"+aMess.getPayloadText()+"<\n");
    }
    catch (java.lang.SecurityException exp) {
    mainScreen.append(getStringTime() + " access denied for receiving SMS\n");
    }
    catch (Exception exp) {
    mainScreen.append(getStringTime() + " problem receiving SMS \n");
    }
    }

    }

Similar Threads

  1. SMS PUSH Registry Problem: Connector.open() throws IOException
    By rexmtorres in forum Mobile Java General
    Replies: 1
    Last Post: 2010-02-26, 01:39
  2. SMS Integration
    By probert in forum General Messaging
    Replies: 0
    Last Post: 2009-10-20, 09:44
  3. Can't update the Counter of SMS
    By localizationer in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-11-16, 04:45
  4. Replies: 2
    Last Post: 2002-10-02, 07:15
  5. Using SMS to update browser
    By IAESTEtom in forum General Messaging
    Replies: 1
    Last Post: 2002-07-10, 06:31

Posting Permissions

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