Introduce the concept of J2ME optional package

xiaoxiao2021-03-06  111

J2ME platform just launched only one configuration (CLDC) and a description (MIDP), but now there are dozens of optional packages can be applied to the J2ME platform, clearly the concept of J2ME optional package is familiar with several important options. Package is a very important part of learning J2ME.

First you should clear the architecture of the J2ME platform. If you are not familiar enough, you can refer to the article below this article http://blog.9cbs.net/mingjava/archive/2004/06/25/26051.aspx.

What is J2ME optional package? The optional package is actually a collection of APIs, but they do not define the running environment of the entire application, but the extension of the standard runtime environment supports specific properties of the specific device, they must be united with Configuration and Profile. For example, NOKIA 3650 is supports CLDC 1.0 MIDP 1.0, and it also provides support for optional package WMA. Usually the device manufacturer controls which optional package can be implemented on his related products. If the optional package is not loaded into the device as a running environment, it is impossible to use them.

For developers, use optional packages, because in fact it is a series of API collections, you only need to use it into classpath, you can use it, and finally packaged, these API packages don't follow Publish, their operating environment is already available on the device. Before you develop, you have already supported your options on your target device, usually we can refer to the development documentation related to the device, and the general official website will be available. You can also test on your device via a small program. Public static boolean iswmapresent () {transname ("javax.wireless.Messaging.MessageConnection); return true;} catch (exception e) {returnaf false;}}

The following brief introduces several options that may be used in our development. If you want to get more information, please refer to Sun's official website http://www.jcp.org/en/jsr/tech?listby=1&listbytype =pletform

RMI Optional Package RMI allows the Java object on a virtual machine to call the Java object running on another virtual machine, and the RMI option package extends this characteristic to the J2ME platform, which is only limited to the support of CDC, due to CLDC lacks support for object serialization so that Java.rmi package has been defined in JSR172. WMA Optional Package WMA Optional Package allows J2ME applications to send and accept information via SMS, WMA extends the universal networked frame of CLDC provides interface javax.wireless.MESSAGING.MESSAGECONNECTION, below is a code snippet using WMA: Import Javax. Microedition.io. *; import javax.wireless.Messaging. *;

...

MessageConnection conn = null; string URL = "SMS: // 417034967891"

Try {conn = (MessageConnection) Connector.Open (URL); TextMessage Msg = Conn.newMessage (CONN.TEXT_MESSAGE); Msg.SetPayLoadText ("please call me!"); conn.send (msg);} catch (Exception E ) {// handle errors} finally {if (con! = Null) {Try {conn.close ();} Catch (Exception E) {}}} 3. MMAPI Optional package Mobile Midea API provides processing multimedia data Support, through it you can play sound video, etc., the following is a simple code description: import java.io. *; Import javax.microedition.media. *;

...

Try {Player P = Manager.createPlayer ("http://somesite.com/music.mp3"); p.Start ();} catch (iOException IoE) {} catch (MediaException me) {} Now you know J2ME The concept of choosing package :)

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

New Post(0)