Differences between Android and j2's (1)

Source: Internet
Author: User
First, I used eclipse to write Android and Program Everyone knows that eclips can quickly create a program through a template, so we will start from creating two simple applications, one of which is j2's and the other is Android's.
The following figure shows the program of the j2-based architecture: Package Cn.edu. BUAA. software;

Import Javax. microedition. MIDlet. MIDlet;
Import Javax. microedition. MIDlet. midletstatechangeexception;

Public   Class Mymidlet Extends MIDlet {

Protected   Void Destroyapp ( Boolean Arg0) Throws Midletstatechangeexception {
//Todo auto-generated method stub

}

Protected   Void Pauseapp () {
//Todo auto-generated method stub

}

Protected   Void Startapp () Throws Midletstatechangeexception {
//Todo auto-generated method stub

}

}

The android program is as follows: Package Cn.edu. BUAA. software;

Import Android. App. activity;
Import Android. OS. Bundle;

Public   Class Myactivity Extends Activity {
/***/ /**Called when the activity is first created.*/
@ Override
Public   Void Oncreate (bundle icicle) {
Super. Oncreate (icicle );
Setcontentview (R. layout. Main );
}
}

To run the two programs, there must be a child class of MIDlet for j2_m2. for Android, there must be a child class of activity. In a sense, these two classes are functionally the same, and they are extremely similar in terms of lifecycles.

The MIDlet of j2's is relatively simple, and only Startapp (), pauseapp (), and destroyapp (Boolean Arg) methods are used for load, pause, and exit (this is a little bit superficial to understand, but it does in simple applications ). Through the above comparison, we can see that Google does not go beyond the idea of J2EE, but only makes its functions more powerful (this is already very valuable ).

For the specific usage of these two classes, I will not describe them here to go to the official API documentation or examples.CodeIt will be more convenient.

These two classes are enough to make the program run normally, but programs without the UI are meaningless to users, next time, I will make a preliminary comparison of the UI presentation of Android and j2's.

Thank you!

Related Article

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.