Implementing the main MIDlet

IAPInfoMIDlet class

Create the main MIDlet class, which creates and shows the IAPTestForm class.

  1. Create the IAPInfoMIDlet class file.

  2. Import the required classes.

    /*
     * Copyright © 2007 Nokia. 
     */
    
    package com.nokia.midp.examples.IAPInfoAPI.iapinfotest;
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    
    
  3. Set IAPInfoMIDlet to extend the MIDlet.

    /**
     * IAPInfoMIDlet.java
     * MIDlet to test the APNInfo implementation
     * 
     * This class extends the class javax.microedition.midlet.MIDlet. This
     * class is the entry point in the example application. The IAPInfoMIDlet class
     * creates and maintains references to an IAPTestForm object.
     * < p >
     * Note that the IAPInfoMIDlet class has no constructor. MIDlet constructors 
     * are not required to do anything because initializing of the object is better 
     * performed in the startApp() method.
     */
     
    public class IAPInfoMIDlet extends MIDlet {
      
  4. Create the three required MIDlet methods for starting, pausing, and ending the application.

        /**
         * This method is called by the runtime
         * at starting the MIDlet. 
         * 
         * Creates the IAPTestForm class, the UI creation
         * is implemented in the IAPTestForm class
         * 
         */
        public void startApp() {
            try{
                IAPTestForm testForm = new IAPTestForm( this );
            }catch( Throwable e){
                System.out.println ( "EXCEPTION:" + e.getMessage ()) ;
                System.err.println( "Exception at startApp method:" + e.toString());
                e.printStackTrace();
            }
        }
        
        public void pauseApp() {
            ;//do nothing
        }
        
        public void destroyApp( boolean unconditional ) {
            ;//do nothing        
        }
    }