×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    Something went wrong runniing this app

    I have a new class called SendSMS Aand the midlet name is Main
    but when i execute the code and i select the send option, it brings a message on the emulator saying"Something went wrong runniing this app"
    correct me please on where i have gone wrong so that when i select send button it brings the textfield for the phone number and also a textbox for the message.
    here is the code:
    the SendSMS is a class of Main Midlet that's why it does'nt extend Midlet.

    public class SendSMS implements CommandListener {
    Display display;
    private TextField toWhom;
    private TextField message;
    private Alert alert;
    private Command SendCommand,exit;
    MessageConnection clientConn;
    private Form compose;
    public SendSMS() {

    display.setCurrent(compose);
    compose=new Form("Compose Message");
    toWhom=new TextField("To","",10,TextField.PHONENUMBER);
    message=new TextField("Message","",600,TextField.ANY);
    SendCommand=new Command("Send",Command.BACK,0);
    exit=new Command("Exit",Command.SCREEN,5);
    compose.append(toWhom);
    compose.append(message);
    compose.addCommand(SendCommand);
    compose.addCommand(exit);
    compose.setCommandListener(this);
    }


    public void commandAction(Command cmd,Displayable disp) {

    if(cmd==SendCommand) {
    String mno=toWhom.getString();
    String msg=message.getString();
    if(mno.equals("")) {
    alert = new Alert("Alert");
    alert.setString("Enter Mobile Number!!!");
    alert.setTimeout(2000);
    display.setCurrent(alert);
    }
    else {
    try {
    clientConn=(MessageConnection)Connector.open("sms://"+mno);
    }
    catch(Exception e) {
    alert = new Alert("Alert");
    alert.setString("Unable to connect to Station because of network problem");
    alert.setTimeout(2000);
    display.setCurrent(alert);
    }
    try {
    TextMessage textmessage = (TextMessage) clientConn.newMessage(MessageConnection.TEXT_MESSAGE);
    textmessage.setAddress("sms://"+mno);
    textmessage.setPayloadText(msg);
    clientConn.send(textmessage);
    }
    catch(Exception e)
    {
    Alert alert=new Alert("Alert","",null,AlertType.INFO);
    alert.setTimeout(Alert.FOREVER);
    alert.setString("Unable to send");
    display.setCurrent(alert) }
    }}}}

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,692

    Re: Something went wrong runniing this app

    Generally you may want to familiarize yourself with the debugger, it is an extremely useful thing and available in most "everyday" programming environments nowadays (including mobile Java). With the emulator it is pretty easy: instead of clicking "Run", click on "Debug". Reading the documentation may also make sense.
    Note that the emulator is not an actual device, depending the one you are using it may or may not support sending SMS-s.

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    48

    Re: Something went wrong runniing this app

    when i click debug in the console it brings java.lang.NullPointerException
    and in the real device when i select send it brings Application error with details: NullPointer java/lang/NullPointerException

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,692

    Re: Something went wrong runniing this app

    Try scattering some breakpoints in the code and see if the debugger really works.
    If this is the first time for testing the debugger, it may make sense creating some new Hello World-like project and experiment with that one, so strange, non-trivial API-s can not interfere.

  5. #5
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: Something went wrong runniing this app

    Please do start using the debugger..its pretty useful.Another simple yet useful tool is the System.out.println(), you can use this to check your progress. Also, your IDE itself should point to the line number where the exception was thrown.

    From reading your code, I can see that you have not initialized the display variable.This could be the reason.

Similar Threads

  1. What's wrong?
    By sundy10 in forum Symbian
    Replies: 3
    Last Post: 2009-09-04, 16:03
  2. what's wrong?
    By ptclin_2007 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2008-03-13, 09:16
  3. help! where wrong?
    By nbm_wolf in forum Symbian
    Replies: 3
    Last Post: 2005-09-16, 09:56
  4. what's wrong with my PDU?
    By njzhoubin in forum General Messaging
    Replies: 0
    Last Post: 2005-02-07, 08:12
  5. What's wrong?
    By drsinisa in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2002-12-04, 19:04

Posting Permissions

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