×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    parameter of DestroyApp()

    When the parameter of DestroyApp() should be true and
    when it should be false?
    Can you please explain me with an example?

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

    Re: parameter of DestroyApp()

    The API specs describes destroyApp()

    protected abstract void destroyApp(boolean unconditional)
    throws MIDletStateChangeExceptionSignals 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

    I had this another interesting article http://onjava.com/pub/a/onjava/excer...x3.html?page=2

    and also this Implementing MIDlet lifecycle requirements

    Regards
    Gopal

  3. #3
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: parameter of DestroyApp()

    destroyApp() is called by the application manager, not by the MIDlet.
    When the application manager call destroyApp()?
    How can the midlet define the parameter value because it was just called by the application manager?
    Because it was just called by the application manager, how can we test that method using the different parameter?

  4. #4
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: parameter of DestroyApp()

    When you are pressing Red key (End Call Key) then destroy App called. I have tested these things on S40 phone .BUt in S60 Phone For Some HAndset Midlet goes hide.
    Anshu Chauhan
    J2me Developer

  5. #5
    Nokia Developer Champion
    Join Date
    Apr 2007
    Posts
    2,708

    Re: parameter of DestroyApp()

    well you can tell the application manager you want the MIDlet to be destroyed, by calling notifyDestroyed()...
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

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

    Re: parameter of DestroyApp()

    Quote Originally Posted by komomo View Post
    destroyApp() is called by the application manager, not by the MIDlet.
    When the application manager call destroyApp()?
    How can the midlet define the parameter value because it was just called by the application manager?
    Because it was just called by the application manager, how can we test that method using the different parameter?
    destroyApp() is not called by the Application Manager, but you can call destroyApp() from the MIDlet.

    For eg: If you have an exit command, > in the commandAction, for exit, you can call destroyApp()

    Code:
    if (c == cmdExit) 
          {
                destroyApp(false);
                notifyDestroyed();
            }
    Regards
    Gopal

Similar Threads

  1. destroyapp() ques
    By dafunkymunky in forum Mobile Java General
    Replies: 4
    Last Post: 2013-07-15, 08:53
  2. destroyapp(true) and destroyapp(false)
    By Manish_Bansal in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2010-04-12, 16:21
  3. destroyApp()
    By TacB0sS in forum Mobile Java Games
    Replies: 3
    Last Post: 2009-08-04, 14:02
  4. Difference between destroyApp(false) and destroyApp(true)
    By Basu in forum Mobile Java General
    Replies: 4
    Last Post: 2008-10-24, 16:09
  5. destroyApp() and exitRequested()
    By Krunoi in forum Mobile Java General
    Replies: 2
    Last Post: 2003-11-10, 18:08

Posting Permissions

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