Basic comparison between Android and j2's

Source: Internet
Author: User
1. The program portal j2s program portal class is MIDlet, and all the j2s programs must inherit this class to initialize the j2s program. The android program Portal is an activity class. Next let's take a look at their lifecycles. This method is called to initialize the resources required by the user when the agent starts. 2. pauseapp (paused) this API is called when a phone call receives a call. You can call this interface to stop or write operations on the thread. 3. called when the destroyapp (destruction status) program exits. You can call this interface to process active threads. The conversion can be called by AMS or by program code. The result of the resumerequest call is that AMS will call the Startapp method. The result of the yypaused call is that AMS may call psuseapp. The notifydestroyed call will destroy the MIDlet. Android activity lifecycle 1. This interface is called when the oncreate program starts initialization. This interface is also called when the user navigation returns to the activity. It is similar to multiple canvase (displayable) switches in j2s. Therefore, the activity is similar to displayable. 2. After onstart oncreate is called, the program calls this interface. 3. onresume onstart calls this interface. At this time, the activity enters the running status. 4. onpause calls this interface when a new activity is started. 5. onstop is called when the activity is invisible. 6. called when the ondestroy program is destroyed. 2. All the components that can be displayed in the display component j2s inherit displayable directly or indirectly, and canvas and screen directly. Different inheritance leads to the difference between low-level UI and advanced UI. All ready-made UI components in j2s directly or indirectly inherit screen. You only need to call display. getdisplay (MIDlet instan). setcurrrent (displayable disp) to display the component on the mobile phone interface. You can also use this interface when switching the interface. Android-visible components directly or indirectly inherit Android. View. View. Activity. setcontentview (view) can be displayed on the Android mobile phone interface. You can also use this interface when switching the interface. If the view is inherited directly, instead of the UI component provided by Android, you must refresh it yourself, similar to the low-level UI component of j2-based. 3. Refresh processing j2's Refresh: the advanced UI component is refreshed internally by the component. The low-level UI can be refreshed through the repain () of the canvas. The low-level UI architecture can be implemented using the MVC method. We recommend that you use the second-level cache. Android Refresh: Android provides the onlayout interface to provide this view to adjust the layout of component elements in it. You only need to rewrite this interface and then OK. Refresh interface ondraw, which is used to refresh the drawing elements in the interface. This interface is similar to the painting interface of the j2_canvas. However, the parameters passed by the two platforms have some meanings. Graphics is used for the upload of j2-based data, while canvas is used for Android. When Android draws the image, a paint parameter is input. This object indicates the painting style, such as color, font size, and font format. If it is a transplant, we recommend that android also use level-2 cache, which is easy to manage. 4. User event handling the keyboard and pen-touch events of j2's are distributed through the canvas-defined interface. You only need to write these interfaces as OK. They are. The keyboard interfaces are keypressed (), keyrepeated (), and keyreleased (). The touch pen interfaces are: pointerpressed (), pointerreleased (), and pointerdragged (). The android keyboard and touch pen are defined in the view, as long as the override interface is OK. Ontouchevent. Soft Keyboard onkeydown (), onkeyup (), ontrackballevent (). 5. Summary Android provides more, more comprehensive, more detailed, and more extensive APIs for programmers to use.

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.