Several basic concepts of learning.
Application Manager (JAM), also known as Application Management Software (AMS) in the specification. This is a native program for executing J2ME applications (Native, representing the C / C ), the application manager is responsible for managing all J2ME applications on the device.
MIDlet: A basic unit that can be performed. In addition to inheriting from Javax.microedition. MIDlet.mIdlet, there is a collection that makes such possible classes and resource files (as long as they are non-Class files are called resource files).
JAR file (JAR file, .jar file): In fact, the file wrapped in MIDlet Suite, belonging to the zip compression format.
Description file (Descriptor file, .jad file): Text files used to describe the basic information of MIDlet Suite, including MIDlet Suite included, or the overall information of MIDlet Suite (files) Size, safety privileges, certificate, etc.), this is an external file (there is no file inside the JAR file, independently existing files).
JAD and JAR content: In theory, each MIDP application is constructed from a JAD file with a JAR file, and the two are unable. However, when you deploy a MIDP application on some devices, the application manager on that device does not require a JAD file, some even produce the corresponding JAD. At the MIDP 1.0, there is a JAD file unrelated to itch. But in MIDP 2.0, whether a JAD file will involve security issues.
The JAD file is a plain text file, so it is some attributes and attribute values. The JAR file contains the MIDLET and other related Class files (auxiliary classes, libraries).
1. resource
The files required when the MIDlet executes, such as pictures, text files, etc., as long as it is not a Class file, it is called a resource. In addition, the specification is provided that the Class file cannot be used as a resource.
2. Manifest File, Manifest.mf)
Used to describe the basic information of a MIDP application, including the MIDlet Suite included in the MIDlet Suite, or the overall information of the MIDlet Suite (name, version number, producer, etc.). This is an internal file (existing in the JAR file).
MIDlet's basic program structure:
Three abstraction methods (Abstract) are defined in the javax.microedition.midlet.midlet class, so we write MIDlets must implement them, these three abstractions are:
l StartApp () Go to the operating state;
l PauseApp () Go to the stop state;
l DestroyApp () turns to the destruction state.
Use display.getdisplay (this) to acquire Display objects that represent the device display screen. From the application manager call () to the MIDLET to end the operation. This time, no matter when DISPLAY.GETDISPLAY (THIS) is called, the acquisition of the same Display object is called. So usually we will reserve the acquired Display object and use it after use. To set the screen displayed on the screen, use the reference to the Display object, and call its setCurrent () method: Display.SetCurrent (subcategory of the DisplayAble class)
Don't write only program code that only needs to perform (eg, initialization) in STARTAPP () because StartApp () is not only performed once in the entire MIDP application.
MIDlet management of your life cycle
The application manager controls the lifecycle of the MIDlet, the MIDlet itself can be softly determined by its own status, but not to change its own state, but MIDLET first calls the corresponding state change function, these functions will be issued. Information Notification Application Manager, please help us change the state of the MIDlet, but the decision is that the application manager is not guaranteed.
Startapp (), pauseapp (), and deStroyApp () are not to control the function of the MIDlet lifecycle, which is just a place to provide us to initialize resources and release resources.
Random number: There is a Random class in the java.util package, which is responsible for generating random numbers (only random number of int or long type). So before use, we must first generate the Random class, you can use Random RDM = New Random (SEEDVALUE); where SeedValue is a random seed. Or you can also use Random RDM = new random (); this constructor will call this internally (System.currentTimeMillis ()); it sets the random number based on the time at the time. At any time we can call SetSeed () to set the random number. We want to customize the range of random numbers, then use some techniques. For example, if you want to generate a value between -160 ~ 160, we must use the remainder operator (%): int res = rdm.nextint ()% 160; if you want to generate between 0 ~ 160 Numerical, since int itself is a number, and is 32 bits. You must set the first bit set to 0 (the positive number), we can use int res = (rdm.nextint () >>> 1)% 160; use a no-shift operator. Or int res = (rdm.nextint () & 0x7fffffff)% 160; set the first bit to 0. Both methods can be. Conversely, if you want to generate a value between -160 ~ 0, just set the first bit to 1. We can add a negative number in front of the method that produces positive numbers. You can also use int res = (RDM.Nextint () | 0x80000000)% 160;
Perfect. . .
Perfect. . .
Perfect. . .
Perfect. . .