×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    3

    destroyapp() ques

    hi guys

    i'm new to j2me and really keen on studing it.. i've been tryin to get some goodtuts and a forum and recently found this site..

    my ques is :: what does "boolean unconditional" mean in destroyapp.. why is the unconditional there. what happens if we dont parse a value to the destroyapp..

    thanks

  2. #2
    Super Contributor
    Join Date
    Nov 2003
    Location
    Bangalore , India
    Posts
    4,430

    Re: destroyapp() ques

    Hi dafunkymunky! Welcome to Nokia Discussion Boards!!

    I guess you question is pretty much explained in API docs itself.
    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.
    MIDlets 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.

    If a Runtime exception occurs during destroyApp then they are ignored and the MIDlet is put into the Destroyed state.

    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.
    What happens if the AMS calls the destroyApp(boolean unconditional) method in the middle of an important step that the MIDlet may be doing, and may be loath to be destroyed? This is where the Boolean unconditional flag comes into the picture. If this flag is set to true, the MIDlet will be destroyed, irrespective of what the MIDlet is doing. However, if this flag is false, effectively, the AMS is telling the MIDlet that it wants the MIDlet to be destroyed, but if the MIDlet is doing something important, it can raise a MIDletStateChangeException, and the AMS will not destroy it just yet. However, note that even then, there are no guarantees that the MIDlet will not be destroyed, and it remains up to each device to decide how they should handle the request. If the device does honor the MIDlet's request, it may try and invoke the destroyApp(boolean unconditional) at a later stage.
    Hope this helps!

    Regards
    Gopal

  3. #3
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: destroyapp() ques

    Hello there,

    Gopal is right. Besides, you can access the entire set of Javadoc pages for JME using -
    http://java.sun.com/javame/reference/apis.jsp#api

    BR,

    Juarez Jr

  4. #4
    Registered User
    Join Date
    Jun 2013
    Posts
    1

    Re: destroyapp() ques

    hi guys!

    I am making a j2me game. The game isn't exiting even when i call Midlet.instance.destroyApp(true); or Midlet.instance.notifyDestroyed(); I've even tried System.exit and Runtime.getRuntime().exit which terminates abruptly ... is there any other of way of ending the app ?

    thanks

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2003
    Posts
    4,104

    Re: destroyapp() ques

    Where do you call it? Is it a CommandListener of a Screen or are you within an Alert?
    Code:
    destroyApp(false);
    notifyDestroyed();
    This ends a MIDlet. If you are within an Alert, does this help? If both do approaches do not help, which phone do you use?

Similar Threads

  1. destroyApp() not called with EndKey 7210
    By Buffalo in forum Mobile Java General
    Replies: 5
    Last Post: 2003-12-05, 14:54
  2. destroyApp not executing fully
    By nirmeidan in forum Mobile Java General
    Replies: 2
    Last Post: 2003-12-04, 14:04
  3. problem not invoke destroyApp method in 3650 phone...
    By crony94 in forum Mobile Java General
    Replies: 3
    Last Post: 2003-06-12, 06:41
  4. urgent Help -destroyAPP not wotking in nokia 6800 phone
    By ferozekadamapuzha in forum Mobile Java General
    Replies: 0
    Last Post: 2003-06-09, 07:45
  5. destroyApp() not working on Series 60???
    By iecomdev in forum Mobile Java General
    Replies: 2
    Last Post: 2003-03-27, 12:25

Posting Permissions

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