Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User natrixnt's Avatar
    Join Date
    Mar 2003
    Posts
    10
    I have develop a
    midlet for send a sms. I use the wma api and when i
    start the app on the phone, i get a exception:

    cannot create class in system package

    when i use the SMS api with the address:

    com.nokia.sms:// and number

    i get a nullpointerexception.
    here my code:


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

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

    public class WmaSend extends MIDlet implements
    CommandListener
    {
    Display display;
    Form mainForm;
    MessageConnection conn;
    TextMessage tmsg;

    Command sendCmd = new Command("Send",
    Command.SCREEN, 1);

    Command exitCmd = new Command("Exit",
    Command.EXIT, 1);

    TextField address = new TextField("Address: ",
    "NUMBER", 200, TextField.ANY);

    ChoiceGroup typeSelect = new
    ChoiceGroup("Messagetyp: ", Choice.EXCLUSIVE, new
    String[] {"Text","Binary"}, null);

    TextField port = new TextField("Port:", "", 5,
    TextField.ANY);

    TextField text = new TextField("Text:", "This is a
    example SMS.", 160, TextField.ANY);

    public WmaSend()
    {
    display = Display.getDisplay(this);
    mainForm = new Form("WmaSend");
    mainForm.append(address);
    mainForm.append(port);
    mainForm.append(typeSelect);
    mainForm.append(text);
    mainForm.addCommand(sendCmd);
    mainForm.addCommand(exitCmd);
    mainForm.setCommandListener(this);
    }
    public void commandAction(Command c, Displayable
    d)
    {
    if(c == sendCmd)
    {
    try
    {
    String addr = "sms://" + address.getString() +
    ((port.getString().length() == 0) ? "" : ":" +
    port.getString());

    try {
    conn =
    (MessageConnection)Connector.open(addr);

    }
    catch (Exception ioe)
    {
    ioe.printStackTrace();


    Alert alert = new Alert("IOError !");
    alert.setString("SMS not send. IOError: " +
    ioe.toString());
    display.setCurrent(alert, mainForm);

    }


    if(typeSelect.getString(typeSelect.getSelectedIndex()).equals("Text"))
    {

    tmsg =

    (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
    try {
    tmsg.setPayloadText(text.getString());
    tmsg =

    (TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
    }
    catch (Exception e2)
    {
    Alert alert = new Alert("SendErroe !");
    alert.setString("Sms not send. CreateError: " +
    e2.toString()+ " "+conn.toString());
    display.setCurrent(alert, mainForm);
    }


    try {
    conn.send(tmsg);
    conn.close();
    }
    catch (Exception e1)
    {
    Alert alert = new Alert("SendErroe !");
    alert.setString("Sms not send. SendError: " +
    e1.toString());
    display.setCurrent(alert, mainForm);
    }


    }
    else

    if(typeSelect.getString(typeSelect.getSelectedIndex()).equals("Binary"))
    {
    BinaryMessage bmsg =

    (BinaryMessage)conn.newMessage(MessageConnection.BINARY_MESSAGE);


    bmsg.setPayloadData(text.getString().getBytes());

    conn.send(bmsg);

    conn.close();
    }
    Alert alert = new Alert("Suuccessful.");



    alert.setString((typeSelect.getString(typeSelect.getSelectedIndex()).equals("Binary")
    ? "Binary" : "Text") + "-SMS sent to " + addr);

    display.setCurrent(alert, mainForm);


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

    Alert alert = new Alert("Error !");
    alert.setString("SMS hallo not send. Error: " +
    e.toString());
    display.setCurrent(alert, mainForm);
    }
    address.setString("");
    port.setString("");
    text.setString("");
    }
    else
    {
    notifyDestroyed();
    }
    }

    public void startApp()
    {
    display.setCurrent(mainForm);
    }

    public void pauseApp()
    {

    }

    public void destroyApp(boolean unconditional)
    {

    }

    }

    where is the mistake?

    thanks for halp

    best regards

    natrix

  2. #2
    Super Contributor shmoove's Avatar
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    What phone are you using. Sounds like it doesn't have WMA or SMS API. These are optional packages and are not included on every phone.

    shmoove

  3. #3
    Registered User natrixnt's Avatar
    Join Date
    Mar 2003
    Posts
    10
    the phone is the 7250i and i know on the phone works wma api and sms api

  4. #4
    Registered User doctordwarf's Avatar
    Join Date
    Jul 2003
    Location
    Finland, Tampere
    Posts
    1,113
    natrixnt

    Try using correct protocol name.

    1.2 Comparison of WMA and the Nokia SMS API

    The Nokia SMS API pre-dates the public release of the Wireless Messaging API, but is functionally very similar. ...
    You should use WMA in your MIDlets in devices where it is available. The differences between the two APIs are summarized in the table below.

    Wireless Messaging API Package name: javax.wireless.messagingcom.nokia.mid.messaging

    SMS URL: "sms://"+<address_part>"

    Nokia SMS API Package name: com.nokia.mid.messaging

    SMS URL: "com.nokia.sms://"+<address_part>
    Taken from "A MIDlet Example Using the WMA and the Nokia SMS API v1.0"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved