Discussion Board

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

    cmd==sendCommand

    i want when i press send button it should bring a phone textfield with a message textfield containing a message of the latest screen
    i should be able to select from a number of screens inoder to send a message of my choice.
    here is my code help me on this;
    private TextField phone;
    private TextField message;
    .
    .
    first=new Form("message (1/50)");
    StringItem item=new StringItem("","This is message one");
    ((Form) first).append(item);
    first.addCommand(NextCommand);
    first.addCommand(get_aboutCommand());
    first.addCommand(get_exitCommand());
    first.addCommand(PreviousCommand);
    first.addCommand(sendCommand);
    first.setCommandListener(this);}
    private void initsecond() {
    second=new Form(" (2/50)");
    StringItem item=new StringItem("", "this is message two.");
    second.addCommand(exitCommand);
    second.append(item);
    second.addCommand(NextCommand);
    second.addCommand(sendCommand);
    second.addCommand(get_aboutCommand());

    second.addCommand(PreviousCommand);
    second.setCommandListener(this);

    }
    private void initthird() {
    third=new Form(" (3/50)");
    StringItem item=new StringItem("", "this is message three.");
    third.append(item);
    third.addCommand(get_aboutCommand());
    third.addCommand(NextCommand);
    third.addCommand(exitCommand);
    third.addCommand(PreviousCommand);
    third.setCommandListener(this);}
    .
    .
    if(cmd==sendCommand){
    Display.getDisplay(this).getCurrent();
    //first=message.getString();



    }

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    272

    Re: cmd==sendCommand

    Hi

    I dont think it is possible to append the same item again and again in multiple forms.A TextField might be too small for a message.Consider TextArea.

    Why are you splitting your screens like this ? If you want to send the text in multiple messages, you could try splitting the string, rather than showing multiple screens.I am not able to understand the purpose behind that.

    Since you have been repeatedly asking questions abt this topic, Do u have any paper prototype of your app? I think sharing that can help us guide u on the approach to take for making the app.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Posts
    4,110

    Re: cmd==sendCommand

    Quote Originally Posted by arunkam View Post
    I dont think it is possible to append the same item again and again in multiple forms.
    It is possible.
    However in Java, one must take care about ‘==’ (same) and ‘equals()’. == requires the same item, it fails with equal items if it is not the same.

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

    Re: cmd==sendCommand

    Here is the link of the prototype http://s0.uploads.im/Ib8rn.jpg

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

    Re: cmd==sendCommand

    Just one question, the second love message is got by pressing the next command right ?

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

    Re: cmd==sendCommand

    Quote Originally Posted by arunkam View Post
    Just one question, the second love message is got by pressing the next command right ?
    yes, it is got by pressing the next command

  7. #7
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    272

    Re: cmd==sendCommand

    Hi

    Check out this code.It will create a bare bone application of what you want.Majority of the things are not implemented , I leave it to you.I hope this helps you along in making the app.

    {CODE]
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package mobileapplication2;

    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.StringItem;
    import javax.microedition.lcdui.TextField;
    import javax.microedition.midlet.*;

    /**
    * @author Ab
    */
    public class Midlet extends MIDlet implements CommandListener
    {

    StringItem si;
    Command next, previous, about, help, send;
    Form main, sms_sending_screen, third, about_form, help_form;

    public void startApp()
    {
    //Creating the stuffs needed for the main screen
    main = new Form("Main Screen");

    si = new StringItem("Message", "Sample Message");

    next = new Command("Next", Command.OK, 1);
    previous = new Command("Previous", Command.OK, 2);
    send = new Command("Send", Command.OK, 3);
    about = new Command("About", Command.OK, 4);
    help = new Command("Help", Command.OK, 5);

    main.addCommand(next);
    main.addCommand(previous);
    main.addCommand(send);
    main.addCommand(about);
    main.addCommand(help);

    main.append(si);

    main.setCommandListener(this);

    showScreen(main);

    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {
    }

    public void commandAction(Command c, Displayable d)
    {
    if (c == next)
    {
    //Set the next message
    si.setText("THE NEXT MESSAGE");
    }
    if (c == previous)
    {
    si.setText("THE PREV MESSAGE");
    }
    if (c == about)
    {
    showAboutForm();
    }
    if (c == help)
    {
    showHelpForm();
    }
    if (c == send)
    {
    sendText();
    }

    }

    public void sendText()
    {
    //It gets the message to be sent from the text presently displayed in the variable si.
    // Add the respective commands to send the sms.
    String message_to_send = si.getText();

    sms_sending_screen = new Form("SMS Sending screen");
    TextField to = new TextField("To", "", 100, TextField.PHONENUMBER);
    StringItem s2 = new StringItem("Message", message_to_send);

    sms_sending_screen.append(to);
    sms_sending_screen.append(s2);

    showScreen(sms_sending_screen);
    }

    public void showScreen(Form formobject)
    {
    Display.getDisplay(this).setCurrent(formobject);
    }

    public void showAboutForm()
    {
    about_form = new Form("About");
    about_form.append("About the app");
    final Command back = new Command("Back", Command.BACK, 1);
    about_form.addCommand(back);
    about_form.setCommandListener(new CommandListener()
    {
    public void commandAction(Command c, Displayable d)
    {
    if (c == back)
    {
    showScreen(main);
    }
    }
    });
    }

    public void showHelpForm()
    {
    //Same as about Form
    }
    }

    [/CODE]

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

    Re: cmd==sendCommand

    thanks arunkam, other buttons are working fine but the send but doesnt fetch a message ffrom the presently displayed screen instead when pressed it says application error.

  9. #9
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    272

    Re: cmd==sendCommand

    Try using a try catch block and find out whats the exact error that you have

Similar Threads

  1. possible to send APDU commands using QNearFieldTarget::sendCommand()?
    By sebastianschaper in forum [Archived] Qt Mobility Project
    Replies: 0
    Last Post: 2012-04-18, 17:35

Posting Permissions

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