×

Discussion Board

Results 1 to 6 of 6

Thread: SMS Aplication

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Exclamation SMS Aplication

    Hello everybody,

    I am new to this subject. I am doing a development for one of my classes. I need to write an sms application (with Java) that sends a SMS. The user will write the SMS, and it will be send with what the user has written and some extra words that the application will add. I have developed with eclipse and eclipseME an example. It runs fine there, but when trying to install on my Nokia E61 says invalid jar! I am new, and don't know what could be happening. If anyone could help me, I would really appreciate. I am writting here the jar I export from eclipse.

    Thanks a lot,

    Jordi

    import java.io.IOException;

    import javax.microedition.midlet.*;
    import javax.microedition.io.Connector;
    import javax.microedition.lcdui.*;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;

    public class Demo extends MIDlet implements CommandListener {
    Alert alerta1, alerta2;

    Command enviar,salir, aler1, aler2;

    Displayable temp;

    Display pantalla;

    Form pantallainicial;

    TextField telefono ;
    TextField mensaje ;

    public Demo(){
    // Obtengo la referencia a la pantalla del MIDlet
    pantalla = Display.getDisplay(this);
    // Creo los objetos que forman las pantallas del MIDlet
    salir = new Command("Salir",Command.EXIT,1);
    enviar = new Command("Enviar",Command.OK,1);
    /*aler1 = new Command("Alerta Modal",Command.SCREEN,1);
    aler2 = new Command("Alerta No Modal",Command.SCREEN,1);*/
    telefono = new TextField ("Numero Telefonico", "", 11, TextField.PHONENUMBER);
    mensaje = new TextField("Mensaje","",120,TextField.ANY);
    // Creo la pantalla de alerta 1
    /*alerta1 = new Alert("Alerta Modal","Esta alerta desaparecer?"+
    "cuando pulses el bot?n de aceptar", null, AlertType.INFO);
    // Creo la pantalla de alerta 2
    alerta2 = new Alert("Alerta No Modal","Esta alerta desaparecera cuando pasen 5 segundos",null,AlertType.INFO);
    alerta1.setTimeout(Alert.FOREVER);
    alerta2.setTimeout(5000);*/
    // Creo la pantalla principal del MIDlet
    pantallainicial = new Form("Jordi Demo");
    pantallainicial.append(telefono);
    pantallainicial.append(mensaje);
    // Inserto objetos en la pantalla
    pantallainicial.addCommand(salir);
    pantallainicial.addCommand(enviar);
    /*pantallainicial.addCommand(aler1);
    pantallainicial.addCommand(aler2);*/
    pantallainicial.setCommandListener(this);
    } public void startApp() {
    pantalla.setCurrent(pantallainicial);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
    if (c == salir) {
    destroyApp(false);
    notifyDestroyed();
    } else if (c == enviar) {
    try {
    MessageConnection mc = (MessageConnection)Connector.open("sms://+"+telefono);

    TextMessage msg = (TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE);
    msg.setPayloadText(mensaje.getString());

    mc.send(msg);

    } catch (IOException e) {
    e.printStackTrace();
    }

    }
    }
    }

  2. #2
    Registered User
    Join Date
    Jul 2006
    Posts
    2

    Exclamation Re: SMS Aplication

    Hello everybody,

    I am new to this subject. I am doing a development for one of my classes. I need to write an sms application (with Java) that sends a SMS. The user will write the SMS, and it will be send with what the user has written and some extra words that the application will add. I have developed with eclipse and eclipseME an example. It runs fine there and on my nokia E61, but when trying to send the sms it is not sended. I am posting my code.

    Thanks a lot,

    Jordi

    import java.io.IOException;

    import javax.microedition.midlet.*;
    import javax.microedition.io.Connector;
    import javax.microedition.lcdui.*;
    import javax.wireless.messaging.MessageConnection;
    import javax.wireless.messaging.TextMessage;

    public class HolaMundo extends MIDlet implements CommandListener {
    private Display pantalla;

    private Form formulario = null;

    private Command salir = null;
    private Command enviar = null;

    private TextField telefono = null;
    private TextField mensaje = null;

    private Alert alerta1 = null;

    private Alert alerta2 = null;

    public HolaMundo(){
    pantalla = Display.getDisplay(this);
    formulario = new Form("Hola Mundo");
    salir = new Command("Salir",Command.EXIT,1);
    enviar = new Command("Enviar",Command.OK,1);

    telefono = new TextField ("Numero Telefonico", "", 11, TextField.PHONENUMBER);
    mensaje = new TextField("Mensaje","",120,TextField.ANY);

    alerta1 = new Alert("Enviando","Si entre", null, AlertType.INFO);
    alerta1.setTimeout(2500);

    alerta2 = new Alert("Error ","Ocurrio un Error", null, AlertType.INFO);
    alerta2.setTimeout(2500);

    formulario.addCommand(salir);
    formulario.addCommand(enviar);

    formulario.append(telefono);
    formulario.append(mensaje);



    formulario.setCommandListener(this);

    }

    public void startApp() {
    pantalla.setCurrent(formulario);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    alerta1 = null;
    telefono = null;
    mensaje = null;
    enviar = null;
    salir = null;
    pantalla = null;
    formulario = null;
    notifyDestroyed();
    }

    public void commandAction(Command c, Displayable d) {

    if (c == salir) {
    destroyApp(false);
    notifyDestroyed();
    } else if(c == enviar){
    try {
    pantalla.setCurrent(alerta1,formulario);

    MessageConnection mc = (MessageConnection)Connector.open("sms://+58+"+telefono);

    TextMessage msg = (TextMessage) mc.newMessage(MessageConnection.TEXT_MESSAGE);
    msg.setPayloadText(mensaje.getString()+" Jordi");

    mc.send(msg);

    } catch (IOException e) {
    pantalla.setCurrent(alerta2,formulario);
    e.printStackTrace();
    }
    }
    }
    }

  3. #3
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: SMS Aplication

    hi jordi,

    welcome aboard!


    it think that simply you are specifying recipient phone number in wrong way,
    your MessageConnection creation code should be something like:
    PHP Code:
    mc = (MessageConnectionConnector.open("sms://+58+"+telefono.getString().trim()); 
    when currently you are simply appending "telefono" TextField converted to String with default toString() method:
    PHP Code:
    mc = (MessageConnection)Connector.open("sms://+58+"+telefono); 
    hth,
    regards,
    Peter

  4. #4
    Registered User
    Join Date
    Jul 2006
    Posts
    15

    Re: SMS Aplication

    u have donw nice program.
    can u tell me how can u place a call using java ME ...
    i dont know , i may not be feasible.
    or tell me some details of TAPI ...
    bye thankz

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: SMS Aplication

    hi,
    @mrtipale
    do you mean voice call? from j2me application?
    afaik that's not possible at least on nokia phones and not defined in midp/cldc specification (generic connection framework),
    http://developers.sun.com/techtopics...ork/index.html

    regards,
    Peter

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: SMS Aplication

    hi mrtipale,
    I haven't answered fully - so to correct my post:
    http://discussion.forum.nokia.com/fo...15&postcount=2
    regards,
    Peter

Similar Threads

  1. Read SMS/ SMS Alert.
    By nirenj in forum General Messaging
    Replies: 3
    Last Post: 2009-01-14, 12:39
  2. Replies: 2
    Last Post: 2007-11-10, 13:19
  3. Error sending SMS
    By jorge_c in forum Multimodecards
    Replies: 0
    Last Post: 2003-10-07, 11:53
  4. How add other SMS aplication
    By Korovkin in forum Multimodecards
    Replies: 0
    Last Post: 2003-08-26, 20:23
  5. Aplication to read the arabic SMS
    By m_otacon in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2003-05-12, 09:43

Posting Permissions

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