×

Discussion Board

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

    Adding code from other midlets

    Guys!!! guide me on this

    I want to connect two midlets as classes to another midlet Main
    I have two midlets but i want to extract some code from another midlet
    the midlet i want to add code to is this one:

    public class Main extends MIDlet implements CommandListener {
    Display display;
    SplashScreen splashScreen;
    private Form menu;
    private TextBox tbHelp,tbAbout;

    private Command AboutCommand=new Command("About",Command.ITEM,1);
    static final Command cmHelp=new Command("Help",Command.HELP,1);
    private Command exitCommand = new Command("EXIT", Command.EXIT,1);
    static final Command mainMenuCommand=new Command("main", Command.SCREEN,1);
    static final Command backCommand=new Command("Back",Command.BACK,0);
    String currentMenu = null;

    protected void startApp() throws MIDletStateChangeException{



    }

    static Image createImage(String filename){
    Image image=null;
    try{
    image=Image.createImage("/icon.png");
    }catch (java.io.IOException ex) {
    }
    return image;
    }
    protected void pauseApp() {}
    protected void destroyApp(boolean unconditional)throws MIDletStateChangeException { }
    public void commandAction(Command cmd, Displayable displayable) {
    if(cmd==exitCommand){ {try {
    destroyApp(true);
    } catch (MIDletStateChangeException e) {
    e.printStackTrace();
    }
    notifyDestroyed();
    } }
    else if(cmd==cmHelp){
    Display.getDisplay(this).setCurrent(tbHelp);
    }
    else if(cmd==AboutCommand){
    Display.getDisplay(this).setCurrent(tbAbout);
    }
    else if(cmd==backCommand){
    Display.getDisplay(this).setCurrent(menu);
    }
    }}





    All i want is for Main midlet to have the codes from these other midlets as may be classes or something
    Last edited by juliusa; 2014-01-22 at 06:41.

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

    Re: Adding code from other midlets

    Hi

    I want u to understand that a MIDlet is like an app itslef.You need not create multiple MIDlets.

    All you need to change is that remove extends MIDlet in NavigationMidlet and SendSMS class..it need not be a MIDlet..It can just be a class with a couple of Forms that take care of all the work to be done within.

    Put the code that you have put in startapp into the constructor itself.Remove startApp, pauseApp and destroyApp in those classes.

    In the Main class which extends MIDlet, create an instance of the two other classes at the right location.That is enough.

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

    Re: Adding code from other midlets

    thanks arunkam now let me do as you have said

Similar Threads

  1. Code Signing Certificates for MIDlets
    By alixwarnke in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2008-02-08, 14:20
  2. Adding midlets to midlet suite dynamically
    By jai99 in forum Mobile Java General
    Replies: 4
    Last Post: 2005-02-16, 08:47
  3. Protecting MIDlets with registration code
    By AF76 in forum Mobile Java General
    Replies: 0
    Last Post: 2004-08-25, 09:16
  4. adding midlets to a deployed suite
    By yonan32 in forum Mobile Java General
    Replies: 2
    Last Post: 2003-12-19, 15:47

Posting Permissions

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