A little bit of experience in the learning process of J2EE

Source: Internet
Author: User


About the MIDlet Lifecycle
After the MIDlet is successfully initialized by the Application Manager, its lifecycle starts to expand.
Basically, the MIDlet has three statuses: Paused, Active, and Destroyed ).
The life cycle of the MIDlet is completely controlled by the Application Manager. Only when the application manager deems that the status of the MIDlet must be changed will the relevant function be called.
At the beginning, the MIDlet must be in the stopped state, and then the application manager converts it to the activated state, and then calls startApp ().
In the activation status, the application manager first converts the MIDlet to the activation status before calling startApp (). The application manager first calls pauseApp () or destroyApp (), and then converts the MIDlet to the stop or destroy state. This means that Active is not passive (no ed at the end of the word), and Paused and Destroyed are the true meaning of passive (plus ed at the end of the word.
If the MIDlet calls these functions by itself, there is usually no error, but the status will not change (the lifecycle of the MIDlet is completely controlled by the application manager ), it can only be used as a simple function call.
StartApp () is called by the Application Manager every time it returns from the stopped status to the activated status. Therefore, actions that only need to be initialized once are not suitable for startApp (). constructors should be used for initialization.
In addition to the application manager to control the life cycle of the MIDlet, The MIDlet itself can also decide its own state, but it does not change its own State, instead, the MIDlet first calls the corresponding request state change function (resumeRequest () -- Request activation, yypaused () -- Notification stop, yydestroyed () -- Notification destroy ), these functions send messages to the Application Manager to help change the status, but the decision is in the Application Manager, which is not guaranteed to be feasible.
The MIDlet calls the request state change function and the application manager require changing the state. The two are different.
Take the stop status as an example: When the Application Manager requires the stop, pasueApp () will call, while pauseApp () will not be called when the MIDlet calls yypaused, however, both of them enable the MIDlet to stop. Therefore, it is recommended that you call pauseApp () first when the MIDlet calls yypaused. The same situation occurs in yydestroyed () and destroyApp (). Unless the system forces the shutdown of the MIDlet, it is recommended that the MIDlet first call destroyApp () and then call yydestroyed (). Ask the application manager to help us turn the MIDlet to the destroy state, end the MIDlet operation. It is useless for the MIDlet to call destroyApp () by itself.
From this we can see that startApp (), pauseApp (), and destroyApp () are not functions that control the MIDlet lifecycle. They are just a place where we initialize resources to release resources!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.