Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MID Profile
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.microedition.midlet
Class MIDlet

    java.lang.Object
      |
      +--javax.microedition.midlet.MIDlet

public abstract class MIDlet
extends Object

A `MIDLet` is a MID Profile application. The application must extend this class to allow the application management software to control the MIDlet and to be able to retrieve properties from the application descriptor and notify and request state changes. The methods of this class allow the application management software to create, start, pause, and destroy a MIDlet. A `MIDlet` is a set of classes designed to be run and controlled by the application management software via this interface. The states allow the application management software to manage the activities of multiple `MIDlets` within a runtime environment. It can select which `MIDlet`s are active at a given time by starting and pausing them individually. The application management software maintains the state of the `MIDlet` and invokes methods on the `MIDlet` to change states. The `MIDlet` implements these methods to update its internal activities and resource usage as directed by the application management software. The `MIDlet` can initiate some state changes itself and notifies the application management software of those state changes by invoking the appropriate methods.

Note: The methods on this interface signal state changes. The state change is not considered complete until the state change method has returned. It is intended that these methods return quickly.

Constructor Summary
`protected` | `MIDlet()` Protected constructor for subclasses.

Method Summary
`protected abstract void` | `destroyApp(boolean unconditional)` Signals the `MIDlet` to terminate and enter the Destroyed state.
`String` | `getAppProperty(String key)` Provides a `MIDlet` with a mechanism to retrieve named properties from the application management software.
`void` | `notifyDestroyed()` Used by an `MIDlet` to notify the application management software that it has entered into the Destroyed state.
`void` | `notifyPaused()` Notifies the application management software that the MIDlet does not want to be active and has entered the Paused state.
`protected abstract void` | `pauseApp()` Signals the `MIDlet` to stop and enter the Paused state.
`void` | `resumeRequest()` Provides a `MIDlet` with a mechanism to indicate that it is interested in entering the Active state.
`protected abstract void` | `startApp()` Signals the `MIDlet` to start and enter the Active state.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MIDlet

    protected MIDlet()

  Protected constructor for subclasses.

Method Detail

### startApp

    protected abstract void startApp()
                              throws MIDletStateChangeException

  Signals the `MIDlet` to start and enter the Active state. In the Active state the `MIDlet` may hold resources. The method will only be called when the `MIDlet` is in the Paused state.

  Two kinds of failures can prevent the service from starting, transient and non-transient. For transient failures the `MIDletStateChangeException` exception should be thrown. For non-transient failures the `notifyDestroyed` method should be called.

  Throws:
    `MIDletStateChangeException` - is thrown if the `MIDlet` cannot start now but might be able to start at a later time.

### pauseApp

    protected abstract void pauseApp()

  Signals the `MIDlet` to stop and enter the Paused state. In the Paused state the `MIDlet` must release shared resources and become quiescent. This method will only be called called when the `MIDlet` is in the Active state.

### destroyApp

    protected abstract void destroyApp(boolean unconditional)
                                throws MIDletStateChangeException

  Signals the `MIDlet` to terminate and enter the Destroyed state. In the destroyed state the `MIDlet` must release all resources and save any persistent state. This method may be called from the Paused or Active states.

  `MIDlet`s should perform any operations required before being terminated, such as releasing resources or saving preferences or state.

  NOTE: The `MIDlet` can request that it not enter the Destroyed state by throwing an `MIDletStateChangeException`. This is only a valid response if the `unconditional` flag is set to `false`. If it is `true` the `MIDlet` is assumed to be in the Destroyed state regardless of how this method terminates. If it is not an unconditional request, the `MIDlet` can signify that it wishes to stay in its current state by throwing the `MIDletStateChangeException`. This request may be honored and the `destroy()` method called again at a later time.

  Parameters:
    `unconditional` - If true when this method is called, the `MIDlet` must cleanup and release all resources. If false the `MIDlet` may throw `MIDletStateChangeException` to indicate it does not want to be destroyed at this time.
  Throws:
    `MIDletStateChangeException` - is thrown if the `MIDlet` wishes to continue to execute (Not enter the Destroyed state). This exception is ignored if `unconditional` is equal to `true`.

### notifyDestroyed

    public final void notifyDestroyed()

  Used by an `MIDlet` to notify the application management software that it has entered into the Destroyed state. The application management software will not call the MIDlet's `destroyApp` method, and all resources held by the `MIDlet` will be considered eligible for reclamation. The `MIDlet` must have performed the same operations (clean up, releasing of resources etc.) it would have if the `MIDlet.destroyApp()` had been called.

### notifyPaused

    public final void notifyPaused()

  Notifies the application management software that the MIDlet does not want to be active and has entered the Paused state. Invoking this method will have no effect if the `MIDlet` is destroyed, or if it has not yet been started.

  It may be invoked by the `MIDlet` when it is in the Active state.

  If a `MIDlet` calls `notifyPaused()`, in the future its `startApp()` method may be called make it active again, or its `destroyApp()` method may be called to request it to destroy itself.

### getAppProperty

    public final String getAppProperty(String key)

  Provides a `MIDlet` with a mechanism to retrieve named properties from the application management software. The properties are retrieved from the combination of the application descriptor file and the manifest. If an attributes in the descriptor has the same name as an attribute in the manifest the value from the descriptor is used and the value from the manifest is ignored.
  Parameters:
    `key` - the name of the property
  Returns:
    A string with the value of the property. `null` is returned if no value is available for the key.

### resumeRequest

    public final void resumeRequest()

  Provides a `MIDlet` with a mechanism to indicate that it is interested in entering the Active state. Calls to this method can be used by the application management software to determine which applications to move to the Active state.

  When the application management software decides to activate this application it will call the `startApp` method.

  The application is generally in the Paused state when this is called. Even in the paused state the application may handle asynchronous events such as timers or callbacks.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| MID Profile
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a comment or suggestion Version 0.95 of MID Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.