×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    notifyDestroyed() not working as expected

    dear forum members,

    its not my first application so please believe i have used it quite often but. My method looks as follows:
    Code:
        private void exitApp() {
    	destroyApp(false);
    	notifyDestroyed();
        }
    i have multiple forms to process, and after a form is processed i got a return value from them and in a switch i will handle the return values and deceide if the app should exit or do different things.

    Code:
    	// check phones capabilities
    	CheckCapabilitiesForm capabilities = new CheckCapabilitiesForm();
    	switch (capabilities.getFormExitValue()) {
    	case CheckCapabilitiesForm.RTYPE_EXIT:
    	    exitApp();
    	    break;
    	default:
    	    break;
    	}
    
    	// show disclaimer
    	DisclaimerForm disclaimer = new DisclaimerForm();
    	switch (disclaimer.getFormExitValue()) {
    	case DisclaimerForm.RTYPE_EXIT:
    	    exitApp();
    	    break;
    	default:
    	    break;
    	}
    you can see in "case DisclaimerForm.RTYPE_EXIT" there should be exit, the program execution is fine at this point but the method exitApp() is then not working, the same is when i directly use notifyDestroyed(). And now i told the wonder its not working on the CheckCapabilitiesForm() switch, in the DisclaimerForm() it is working properly as expected. Because of this i experiment around and test it simply:
    Code:
    public class CallAVelo extends MIDlet {
        
        protected void startApp() {
    	destroyApp(false);
    	notifyDestroyed();
    (this is only a snip) but this is also not working. it seems as it must a little piece of code be executed. I am really confused, i also take care that all threads they are running may stopped before, checekd with Thread.activeCount(); A good hint will be appreciated.

    Many Thanks for reading this post
    Daniel

  2. #2
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by drindt View Post
    dear forum members,

    its not my first application so please believe i have used it quite often but. My method looks as follows:
    Code:
        private void exitApp() {
    	destroyApp(false);
    	notifyDestroyed();
        }
    Welcome to the Forum Nokia Discussion Boards!!
    Why are you passing the false parameter..?
    was there any exception like MIDletStateChangeException, test this by putting the lines in the exception handlers?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: notifyDestroyed() not working as expected

    Try destroyApp(true)

    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:
    - 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.

    or if you want to try with false, put a try/catch block and you will see MIDletStateChangeException, if you wantt o force it exit - put destroyApp(true) in the finally block of this try catch block.

  4. #4
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    Re: notifyDestroyed() not working as expected

    I found that issue, i can't use notifyDestroyed on multiple Locations. The usage of notifyDestroyed in appDestroy is not required. Because appDestroy is only invoked by the AMS, and its not recommended to invoke destoryApp.

    To share this experience with interested poeple i show you my new version:
    Code:
        protected void startApp() {
    	Display.init(this);
    	AppConfigManager.init(this);
    	Resources resources = null;
    
    	try {
    	    resources = Resources.open("/theme.res");
    	} catch (IOException ex) {
    	}
    	UIManager.getInstance().setThemeProps(
    		resources.getTheme(resources.getThemeResourceNames()[0]));
    
    	// set locale
    	String locale = System.getProperty("microedition.locale").substring(0,
    		2);
    
    	UIManager.getInstance().setResourceBundle(
    		resources.getL10N("l10n", locale));
    
    	// check phones capabilities
    	if (new CheckCapabilitiesForm().getFormExitValue() == CheckCapabilitiesForm.RTYPE_CONTINUE) {
    	    // show disclaimer
    	    if (new DisclaimerForm().getFormExitValue() == DisclaimerForm.RTYPE_CONTINUE) {
    		// do the order
    		new OrderForm();
    	    }
    	}
    	notifyDestroyed();
        }

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: notifyDestroyed() not working as expected

    What is happening using the code that you share now?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by raj_J2ME View Post
    What is happening using the code that you share now?
    The first code is invoking notifyDestroy() on multiple place, after modifiying that notifyDestroyed() invoked just once in startApp its working. So i have no idea why its not working, because in no papers i can read about such behavior. BTW iam using WTK 2.5.2 (Linux).

  7. #7
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by drindt View Post
    The first code is invoking notifyDestroy() on multiple place, after modifiying that notifyDestroyed() invoked just once in startApp its working. So i have no idea why its not working, because in no papers i can read about such behavior. BTW iam using WTK 2.5.2 (Linux).
    I guess there is no sense to calling this notifyDestroyed() method multiple times. Since you can only exit the application/midlet just in a go..and once for the session. Do you have any special point to make multiple calls to the notifyDestroyed() method..
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  8. #8
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by raj_J2ME View Post
    Do you have any special point to make multiple calls to the notifyDestroyed() method..
    I have multiple Buttons to Exit the App.

  9. #9
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by drindt View Post
    I have multiple Buttons to Exit the App.
    But as you said you have only one method, so the same method will be called isn't it?
    private void exitApp() {
    destroyApp(false);
    notifyDestroyed();
    }
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  10. #10
    Registered User
    Join Date
    Dec 2009
    Posts
    9

    Re: notifyDestroyed() not working as expected

    Quote Originally Posted by raj_J2ME View Post
    But as you said you have only one method, so the same method will be called isn't it?
    Yes, i call the exitApp() on multiple points, but it is only working when no code following afterwards. So the restructured mechanism works well and also displays great even when its a small structure but you can quickly see how the main construct is working.

  11. #11
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Thumbs up Re: notifyDestroyed() not working as expected

    Quote Originally Posted by drindt View Post
    Yes, i call the exitApp() on multiple points, but it is only working when no code following afterwards. So the restructured mechanism works well and also displays great even when its a small structure but you can quickly see how the main construct is working.
    okay..however that is obvious, if you are gonna kill/exit from the application, so first you will do all the tasks that are supposed to be done, and the at last application must exit.It should not be like that application was doing something now and then detects the call to any of the method used to exit the application and after that you expect to some more operations.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. Strange problems after changing resource file
    By jewel87 in forum Symbian
    Replies: 2
    Last Post: 2009-12-08, 19:28
  2. Problem with math.h please help
    By Mozart2007 in forum Symbian
    Replies: 13
    Last Post: 2009-08-05, 07:33
  3. Math.h includes non-existant file
    By tamhanna in forum Symbian
    Replies: 3
    Last Post: 2009-07-31, 06:58
  4. variable list argument not working as expected
    By wit_anshul in forum Open C/C++
    Replies: 2
    Last Post: 2009-07-24, 13:16
  5. sendRedirect not working
    By nicole_yap in forum Mobile Java General
    Replies: 0
    Last Post: 2005-09-16, 03:35

Posting Permissions

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