Learn j2me_1 together: Write a property display program for the mobile phone system (with error code for the JAD file)

Source: Internet
Author: User

Objective: To write a mobile phone system property display program sysinfomidlet

 

Development Environment: netbeans4.1

Test Model: Sun defacolorcolorphone

Real machine model: Nokia 6030

 

 

Function implementation:

1. Display mobile phone system attributes

2. ability to respond to the messages of the up and down arrow keys, so that the attribute information queue can be displayed in a scrolling manner on the screen.

3. ability to respond to the left-and right-direction key message, so that long attribute information can be moved on the screen left and right, so that users can see all the content of the attribute information.

4. Set the font size and adjust the line spacing based on the font size.

 

The Code is as follows, which will be added after the annotation:

 

File 1: sysinfomidlet. Java

Import javax. microedition. MIDlet. MIDlet; <br/> Import javax. microedition. lcdui. game. gamecanvas; <br/> Import javax. microedition. lcdui. *; <br/> public class sysinfocanvas extends gamecanvas implements runnable, <br/> commandlistener {<br/> display; <br/> font F = font. getfont (font. face_system, Font. style_plain, Font. size_medium); <br/> Boolean isplay = true; <br/> int arraylength = 33; <br/> int SCR Eenwidth = 0; <br/> int screenheight = 0; <br/> int fontdis = 0; <br/> byte move = 4; <br/> string [] propertystr = new string [arraylength]; <br/> int [] strlength = new int [arraylength]; <br/> int [] [] loca = new int [arraylength] [3]; <br/> MIDlet; <br/> Public sysinfocanvas (MIDlet mid, display dis) {<br/> super (true); <br/> MIDlet = mid; <br/> display = DIS; <br/> setfullscreenmode (true); <br/> screenwid Th = getwidth (); <br/> screenheight = getheight (); <br/> getproperty (); <br/> fontdis = f. getheight () + 2; <br/> for (Int J = 0; j <arraylength; j ++) {<br/> loca [J] [2] = f. stringwidth (propertystr [J]); <br/> loca [J] [1] = J * fontdis; <br/> loca [J] [0] = 0; <br/>}< br/> addcommand (new command ("font", command. screen, 1); <br/> addcommand (new command ("font", command. screen, 1); <br/> addcommand (new command ("Small character Body ", command. screen, 1); <br/> addcommand (new command ("quit", command. exit, 1); <br/> setcommandlistener (this); <br/>}< br/> Public void start () {<br/> isplay = true; <br/> New thread (this ). start (); <br/>}< br/> Public void stop () {<br/> isplay = false; <br/>}< br/> Public void run () {<br/> graphics G = getgraphics (); <br/> while (isplay) {<br/> input (); <br/> drawscreen (g); <br/> try {<br/> thread. sleep (80 ); <Br/>} catch (interruptedexception IE) {<br/> IE. printstacktrace (); <br/>}< br/> private void drawscreen (Graphics g) {<br/> G. setcolor (0xffff00); <br/> G. fillrect (0, 0, screenwidth, screenheight); <br/> drawsodino (g); <br/> G. setcolor (0x000000); <br/> property (g); <br/> flushgraphics (); <br/>}< br/> Public void drawsodino (Graphics g) {<br/> G. setcolor (0xf813); <br/> font F = font. getfont (Font. face_proportional, Font. style_bold <br/> | font. style_italic, Font. size_large); <br/> G. setfont (f); <br/> for (INT I = 0; I <6; I ++) {<br/> G. drawstring ("sodino", 30, I * 20, graphics. left | graphics. top); <br/>}< br/> Public void input () {<br/> int key = getkeystates (); <br/> int temp = 0; <br/> If (up_pressed = Key) {<br/> temp = loca [0] [1]; <br/> for (Int J = 0; j <arraylength-1; j ++) {<Br/> loca [J] [1] = loca [J + 1] [1]; <br/>}< br/> loca [arraylength-1] [1] = temp; <br/>} else if (down_pressed = key) {<br/> temp = loca [arraylength-1] [1]; <br/> for (Int J = arraylength-1; j> 0; j --) {<br/> loca [J] [1] = loca [J-1] [1]; <br/>}< br/> loca [0] [1] = temp; <br/>} else if (left_pressed = key) {<br/> for (INT I = 0; I <arraylength; I ++) {<br/> If (loca [I] [1]> = 0 <br/> & loca [I] [1] + F. getheight () <= screenheight <br/> & 0> loca [I] [0]) {<br/> loca [I] [0] + = move; <br/>}< br/>} else if (right_pressed = Key) {<br/> for (INT I = 0; I <arraylength; I ++) {<br/> If (loca [I] [1]> = 0 <br/> & loca [I] [1] + F. getheight () <= screenheight <br/> & screenwidth <loca [I] [0] + loca [I] [2]) {<br/> loca [I] [0]-= move; <br/>}< br/> Public void property (Graphics g ){ <Br/> G. setfont (f); <br/> propertystr [arraylength-2] = "currently available memory:" <br/> + runtime. getruntime (). freememory (); <br/> system. GC (); <br/> propertystr [arraylength-1] = "Maximum idle memory:" <br/> + runtime. getruntime (). freememory (); <br/> for (INT I = 0; I <arraylength; I ++) {<br/> G. drawstring (propertystr [I], loca [I] [0], loca [I] [1], graphics. left <br/> | graphics. top); <br/>}< br/> Public void commandaction (C Ommand C, displayable dis) {<br/> If (C. getlabel (). equals ("exit") {<br/> MIDlet. policydestroyed (); <br/>} else if (C. getlabel (). equals ("font") {<br/> F = font. getfont (font. face_system, Font. style_plain, <br/> font. size_large); <br/> resetstringwidth (); <br/> modifyloca1 (); <br/>} else if (C. getlabel (). equals ("font") {<br/> F = font. getfont (font. face_system, Font. style_plain, <br/> font. size_medium); <br /> Resetstringwidth (); <br/> modifyloca1 (); <br/>} else if (C. getlabel (). equals ("small font") {<br/> F = font. getfont (font. face_system, Font. style_plain, <br/> font. size_small); <br/> resetstringwidth (); <br/> modifyloca1 (); <br/>}< br/> Public void modifyloca1 () {<br/> int thetoploca = 0; <br/> for (INT I = 0; I <arraylength; I ++) {<br/> If (0 = loca [I] [1]) {<br/> thetoploca = I; <br/> break; <br/>} <BR/>}< br/> for (INT I = thetoploca + 1; I <thetoploca + arraylength; I ++) {<br/> int temp = I % arraylength; <br/> If (temp = 0) {<br/> loca [0] [1] = loca [arraylength-1] [1] + fontdis; <br/>} else {<br/> loca [temp] [1] = loca [temp-1] [1] + fontdis; <br/>}< br/> Public void resetstringwidth () {<br/> propertystr [arraylength-4] = "current font Height:" + F. getheight (); <br/> fontdis = f. getheight () + 2; <br/> for (INT I = 0; I <arraylength; I ++) {<br/> loca [I] [2] = f. stringwidth (propertystr [I]); <br/>}< br/> Public void getproperty () {<br/> propertystr [0] = "MIDP: "+ system. getproperty ("microedition. profiles "); <br/> propertystr [1] =" cldc: "<br/> + system. getproperty ("microedition. configuration "); <br/> propertystr [2] =" character package: "+ system. getproperty ("microedition. encoding "); <br/> pro Pertystr [3] = "Mobile Phone country:" + system. getproperty ("microedition. locale "); <br/> propertystr [4] =" Mobile Phone model: "+ system. getproperty ("microedition. platform "); <br/> propertystr [5] =" serial port list: "<br/> + system. getproperty ("microedition. commp orts "); <br/> propertystr [6] =" Mobile Phone name: "+ system. getproperty ("microedition. hostname "); <br/> propertystr [7] =" sound mixing supported: "+ system. getproperty ("supports. mixing "); <br/> propertystr [8] = "Video Capture:" <br/> + system. getproperty ("supports. audio. capture "); <br/> propertystr [9] =" sound Capture: "<br/> + system. getproperty ("supports. vedio. capture "); <br/> propertystr [10] =" Video Format: "+ system. getproperty ("audio. encoding "); <br/> propertystr [11] =" sound format: "+ system. getproperty ("vedio. encodings "); <br/> propertystr [12] =" supported records: "+ system. getproperty ("supports. recording "); <br/> propertystr [13] =" 3D: "< Br/> + system. getproperty ("microedition. m3G. version "); <br/> If (true = display. flashbacklight (2500) {<br/> propertystr [14] = "Flashing background light: True "; <br/>} else {<br/> propertystr [14] = "background light flashing: false"; <br/>}< br/> If (true = display. vibrate (500) {<br/> propertystr [15] = "vibration supported: True "; <br/>} else {<br/> propertystr [15] = "vibration supported: false"; <br/>}< br/> If (true = display. iscolor () {<br/> propertystr [16] = "Color: True"; <br/> propertystr [17] = "color count:" + display. numcolors (); <br/>} else {<br/> propertystr [16] = "color: false "; <br/> propertystr [17] = "number of colors: white and black only"; <br/>}< br/> If (true = This. hasrepeatevents () {<br/> propertystr [18] = "continuous buttons: True "; <br/>}else {<br/> propertystr [18] = "continuous buttons: false"; <br/>}< br/> If (true = This. haspointerevents () {<br/> propertystr [19] = "pointer event: T Rue "; <br/>}else {<br/> propertystr [19] =" pointer event: false "; <br/>}< br/> If (true = This. haspointermotionevents () {<br/> propertystr [20] = "drag a pointer: True "; <br/>} else {<br/> propertystr [20] = "drag a pointer: false"; <br/>}< br/> If (true = This. isdoublebuffered () {<br/> propertystr [21] = "Double Cache supported: True "; <br/>} else {<br/> propertystr [21] = "dual cache supported: false "; <br/>}< br/> propertystr [22] = "Bluetooth version:" <br/> + system. g Etproperty ("Bluetooth. API. version "); <br/> propertystr [23] =" SMS service center number: "<br/> + system. getproperty ("wireless. messaging. SMS. SMSC "); <br/> propertystr [24] =" mobile phone memory card name: "<br/> + system. getproperty ("fileconn. dir. memorycard. name "); <br/> propertystr [25] =" streaming media format: "+ system. getproperty ("streamable. contents "); <br/> propertystr [arraylength-7] =" IMEI: "+ getimei (); <br/> propertystr [arraylength-6] =" L AC: "+ getlac (); <br/> propertystr [arraylength-5] =" cellid: "+ getcellid (); <br/> propertystr [arraylength-4] = "font Height:" + F. getheight (); <br/> propertystr [arraylength-3] = "total memory:" <br/> + runtime. getruntime (). totalmemory (); <br/> propertystr [arraylength-2] = "Current idle memory:" <br/> + runtime. getruntime (). freememory (); <br/> propertystr [arraylength-1] = "Maximum idle memory:" <br/> + runtime. getruntime (). totalmem Ory (); <br/>}< br/> private string getimei () {<br/> return (system. getproperty ("com. sonyericsson. IMEI ") = NULL? System <br/>. getproperty ("com. Nokia. IMEI") = NULL? System <br/>. getproperty ("com. Nokia. Mid. IMEI") = NULL? System <br/>. getproperty ("phone. IMEI") = NULL? System. getproperty ("IMEI") = NULL? System <br/>. getproperty ("com. Samsung. IMEI") = NULL? System <br/>. getproperty ("com. Siemens. IMEI") = NULL? "Null": System <br/>. getproperty ("com. siemens. IMEI "): System <br/>. getproperty ("com. samsung. IMEI ") <br/>: system. getproperty ("IMEI") <br/>: system. getproperty ("phone. IMEI ") <br/>: system. getproperty ("com. nokia. mid. IMEI ") <br/>: system. getproperty ("com. nokia. IMEI ") <br/>: system. getproperty ("com. sonyericsson. IMEI "); <br/>}< br/> private string getlac () {<br/> return (system. getproperty ("com. sonye Ricsson.net. Lac ") = NULL? System <br/>. getproperty ("com. Nokia. Mid. Lac") = NULL? System <br/>. getproperty ("locareacode") = NULL? "Null": System <br/>. getproperty ("locareacode"): System <br/>. getproperty ("com. nokia. mid. LAC "): System <br/>. getproperty ("com.sonyericsson.net. LAC "); <br/>}< br/> private string getcellid () {<br/> return (system. getproperty ("com.sonyericsson.net. cellid ") = NULL? System <br/>. getproperty ("com. Nokia. Mid. cellid") = NULL? System <br/>. getproperty ("com. Samsung. cellid") = NULL? System <br/>. getproperty ("com. Siemens. cellid") = NULL? "Null": System <br/>. getproperty ("com. siemens. cellid "): System <br/>. getproperty ("com. samsung. cellid "): System <br/>. getproperty ("com. nokia. mid. cellid ") <br/>: system. getproperty ("com.sonyericsson.net. cellid "); <br/>}< br/>}

 

 

 

I am studying j2's, And I will share my experience with you on the Internet. I am reminding you of the shortcomings of my fairy brothers and gods who are waiting to pass. Thank you !!!!!!!!

 

 

Error code of the attached JAD file:

 

Jad (Java application discriptor)
Files are an important part of the j2's architecture. When we release the j2's program, Jad files often report various errors, such:
Com. Sun. kvem. midletsuite. invalidjadexception: reason = 13
The cause of the error is
The code from 1 to 52 is confusing. I found the explanations of these codes on the Internet and shared them with you as follows:

Public static final int
Jad_server_not_found = 1;
Public static final int jad_not_found =
2;
Public static final int missing_provider_cert = 4;
Public
Static final int corrupt_provider_cert = 5;
Public static final int
Unknown_ca = 6;
Public static final int invalid_provider_cert = 7;
Public static final int corrupt_signature = 8;
Public static final
Int invalid_signature = 9;
Public static final int
Unsupported_cert = 10;
Public static final int
Expired_provider_cert = 11;
Public static final int expired_ca_key =
12;
Public static final int missing_suite_name = 13;
Public
Static final int missing_vendor = 14;
Public static final int
Missing_version = 15;
Public static final int invalid_version = 16;
Public static final int old_version = 17;
Public static final int
Missing_jar_url = 18;
Public static final int jar_server_not_found =
19;
Public static final int jar_not_found = 20;
Public static
Final int missing_jar_size = 21;
Public static final int
Suite_name_mismatch = 25;
Public static final int version_mismatch =
26;
Public static final int vendor_mismatch = 27;
Public
Static final int invalid_key = 28;
Public static final int
Invalid_value = 29;
Public static final int insufficient_storage =
30;
Public static final int jar_size_mismatch = 31;
Public
Static final int new_version = 32;
Public static final int
Unauthorized = 33;
Public static final int jad_moved = 34;
Public static final int cannot_auth = 35;
Public static final int
Corrupt_jar = 36;
Public static final int invalid_jad_type = 37;
Public static final int invalid_jar_type = 38;
Public static final
Int already_installed = 39;
Public static final int
Device_incompatible = 40;
Public static final int
Missing_configuration = 41;
Public static final int missing_profile
= 42;
Public static final int invalid_jad_url = 43;
Public
Static final int invalid_jar_url = 44;
Public static final int
Push_dup_failure = 45;
Public static final int push_format_failure =
46;
Public static final int push_proto_failure = 47;
Public
Static final int push_class_failure = 48;
Public static final int
Authorization_failure = 49;
Public static final int
Attribute_mismatch = 50;
Public static final int proxy_auth = 51;
Public static final int trusted_overwrite_failure = 52;
With the explanation of these codes,
We can easily find out the cause of the error.
In addition, you know that some mobile phones do not need Jad files when installing jar files. This is because the mobile phone manufacturer has a built-in parsing function for jar files in the operating system. Just like automatic generation of mobile phones
And then use the JAD file to install the JAR file.

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.