J2ME (4) in Java embedded development

xiaoxiao2021-03-06  38

Author: Move2008 Source: Move2008.com talk about the fourth quarter, although J2ME profiles configured to provide a set of common equipment smallest Java platform, but application developers interested for an individual device production applications, when they Just use configuration, the application they have written will have some lacking. Configuration must meet the minimum requirements of all devices, user interfaces, input mechanisms, and data persistence have highly devices, each device has its own user interface, input mechanism, and data storage methods, these are often not configured Within the minimum requirements of satisfaction. The brief watch provides a standardized Java class library for different manufacturers of the same consumer electronics. In fact, although the development of configuration specifications is leaders in Sun leadership, many of the briefs will continue to lead the supplier of special equipment. For example, Motorola led the development of a mobile phone and caller's brief mesh specification, as well as the development of PDA briefings. Now, five known briefings have been normative, remember, each brief watch is to improve the deficiencies of the configuration, the following table lists these five shortcomings: Brief Table Improve Mobile Information DEVICES PROFILE MIDP) Mobile Phone and Calls CLDC Personal Digital Assistant Profile Palm and Handspring PDA Device CLDC Foundation Profile For all CDC Personal Profile without GUI CDC Personal Profile replaces the Foundation of Personaljava Foundation CDC RMI Profile provides RMI Foundation Perfect Summary CDC Now I want to talk about another Java class library set, it is now almost considered to be another brief watch. When Sun develops the first KVM for Palm, they need a class to develop Palm's demos. This set of libraries are packaged into the com.sun.kjava package, in the early development of CLDC, these classes are widely used to test and demonstrate J2ME. Because Kjava is the only class that allows application developers to develop applications using J2ME and KVM, it is widely used. Even today, a brief table for PDA or more special Palm has been developed, and many developers still want to use the KJAVA class to develop PDA applications. Although the KJAVA class is not supported and is only used for design test programs or demos, they will be replaced by an upcoming briefing, but developers are still keen to use it to develop. Midp Mobile Information Device Profile (MIDP) , Dual channel calls and other radios. Because both MIDP and CLDC have reference implementations, we can use a routine to study this brief. The following example is an example of a code that allows users to enter a code that represents the fund quotes you want to know. Application then receives a financial website via HTTP, gets the fund quotation, store the price in a database, then return the price to the user.

// To the J2ME IMPORT JAVAX.MICROEDITIDLET. *; Import javax.microedition.lcdui. *; Import javax.microedition.rms. *; // extension MIDlet class to build our custom MIDLETPUBLIC CLASS FundTracker Extends MIDlet implements CommandListener {file: // display manager variable private display display = null; file: // MIDlet form variable private RequestForm reqForm = null; file: // MIDlet builder public FundTracker () {display = Display.getDisplay ( This); Reqform = New RequestForm ("Fund Tracker"); ReqForm.initForm (); ReqForm.SetCommandListener (this);} file: // Start MIDlet application protected void startapp () {Display.setCurrent (reqform);} file: // pause Midletprotected void pauseApp () {} file: // destruction Midletprotected void destroyApp (boolean unconditional) {} file: // response command public void commandAction (command c, Displayable s) {if (c = listeners by = Reqform.GetexitCommand ()) {destroyApp (false); NOTIFYDESTROYED (); return;} if ((c == reqform.getGetCommand ()) && () ") && (). Length (). getString (). Length ()> 0) ) {getanddisplayquote ();} else {reqform.getmsgstring (). settext ("Symbol Required");}} file: // Store the pair of subsets Gold strings and string offer private void storeQuote (String fund, String newQuote) {file: // database variable RecordStore quoteDB = null; try {quoteDB = RecordStore.openRecordStore ( "FundQuotes", true); byte [] data = ( Fund "#" newquote) .GetBytes (); int size = data.length; quotedb.addrecord (DATA, 0, size); quotedb.closecordstore ();} catch (exception recordexception) {system.out.println "Unable to store quote");}} file: // Remove the submission submitted by the QuoteService class, the fund quoted fund quotation private void getanddisplayquote () {string fundsymbol = ReqForm.getsymfield (). GetString (); if (Fundsymbol.Length ()> 0) {string thequote = quoteService.getQuote (Fundsymbol);

转载请注明原文地址:https://www.9cbs.com/read-62493.html

New Post(0)