javax.microedition.midlet.MIDletStateChangeException : MIDletStateChangeException « javax.microedition.midlet « Java by API






javax.microedition.midlet.MIDletStateChangeException

  


/* License
 * 
 * Copyright 1994-2004 Sun Microsystems, Inc. All Rights Reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *  
 *  * Redistribution of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 * 
 *  * Redistribution in binary form must reproduce the above copyright notice,
 *  this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of Sun Microsystems, Inc. or the names of contributors
 * may be used to endorse or promote products derived from this software
 * without specific prior written permission.
 *  
 * This software is provided "AS IS," without a warranty of any kind. ALL
 * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
 * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
 * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
 * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
 * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
 * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
 * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
 * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
 *  
 * You acknowledge that this software is not designed, licensed or intended
 * for use in the design, construction, operation or maintenance of any
 * nuclear facility. 
 */

/* imports  */

import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class Main extends MIDlet {
  /**
   * PropertyOutput - lookup and report one application property.
   */

  private void PropertyOutput(String key) {
    String value = getAppProperty(key);

    if (value != null)
      System.out.println(key + " = " + value);
  }

  /**
   * PropertyReport - detect and report MIDlet run-time environment.
   */

  private void PropertyReport() {
    final int Npush = 10; /* maximum number of Push's to report */
    final int Nmidlet = 10; /* maximum number of MIDlet's to report */
    final String key[] = { /* standard names */
    "MIDlet-Name", "MIDlet-Version", "MIDlet-Vendor", "MIDlet-Icon",
        "MIDlet-Description", "MIDlet-Info-URL", "MIDlet-Jar-URL",
        "MIDlet-Jar-Size", "MIDlet-Data-Size", "MicroEdition-Profile",
        "MicroEdition-Configuration", "MIDlet-Permissions",
        "MIDlet-Permissions-Opt", "MIDlet-Install-Notify",
        "MIDlet-Delete-Notify", "MIDlet-Delete-Confirm", null };
    final String push_key = "MIDlet-Push-";
    final String midlet_key = "MIDlet-";
    int i;

    for (i = 0; key[i] != null; ++i)
      /* report standard properties */
      PropertyOutput(key[i]);

    for (i = 1; i <= Npush; ++i)
      /* report push entries */
      PropertyOutput(push_key + i);

    for (i = 1; i <= Nmidlet; ++i)
      /* report MIDlet entries */
      PropertyOutput(midlet_key + i);

    return;
  }

  /**
   * MyMIDlet - constructor
   */

  public Main() {
    PropertyReport();
  }

  /**
   * startApp - MIDlet has entered the Active state.
   */

  public void startApp() {
  }

  /**
   * pauseApp - enter the Paused state.
   */

  public void pauseApp() {
  }

  /**
   * destroyApp - enter the Destroyed state.
   * 
   * @param unconditional
   */

  public void destroyApp(boolean unconditional)
      throws MIDletStateChangeException {
    if (unconditional == false) {
      throw new MIDletStateChangeException();
    }
  }
}
/*

Running with storage root C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\MediaControlSkin
Running with locale: English_United States.1252
Running in the identified_third_party security domain
No audio device found.
MIDlet-Name = Main Midlet Suite
MIDlet-Version = 1.0.0
MIDlet-Vendor = Midlet Suite Vendor
MIDlet-Jar-URL = Main.jar
MIDlet-Jar-Size = 1691
MicroEdition-Profile = MIDP-2.0
MicroEdition-Configuration = CLDC-1.1
Execution completed.
3399135 bytecodes executed
166 thread switches
1667 classes in the system (including system classes)
17751 dynamic objects allocated (535200 bytes)
2 garbage collections (457948 bytes collected)

*/

   
    
  








Related examples in the same category