J2ME software development of high portability

2010-03-29  来源:本站原创  分类:Mobile  人气:398 

With the popularity of MTK, so that the current J2ME virtual machine on the market many brands, in addition to Sony Ericsson, Nokia S40, Moto, Samsung, LG and other major international brands of virtual machines, but there is a MTK, Spreadtrum built some of the unknown virtual machine, so the original Write Once, Run AnyWhere into a Write Once, Debug AnyWhere of. For an inexperienced J2ME programmers to develop a high compatibility of software into a nightmare, constantly in a different mobile phones, playing on different platforms, log, in which mobile phones to solve this problem, go to another one problems on the machine again, and oh, my god! I quit. But wait! The purpose of this article I write is to tell you that, for this situation, we are not helpless. Here's waiting for me slowly Road to solution.

In this paper, suitable for those who have experienced J2ME programmer optimization software, or software compatibility need to be considered when the reference documentation.

Jblend Platform

JBlend is a Japanese manufacturer of embedded virtual machine produced by J2ME virtual machine, this virtual machine for a large number of low-end mobile phone platforms, I found that using this virtual machine platform has, MTK, MOTO.

Official website: http://www.aplixcorp.com/chs/index.html.

Sony Ericsson Platform

Sony Ericsson Virtual Machine platform: Java Platform. The latest version is 8. Sony Ericsson's platform performance, the program's stability is superior to other virtual machine platforms. And the APIs in the bug is also very little support in the network is also very good. Basically, because you will not forget the close connection which caused the connection to leak.

Official Website: http://developer.sonyericsson.com/site/zhcn/docs_and_tools/p_docs_and_tools.jsp

S40 Platform

Nokia for the S40 platform is the introduction of S60 smartphone operating system to adapt to low-end mobile phone operating system, compared to other virtual machine platform,, S40 support for J2ME virtual machine on a relatively sound and stable more, but this piece of the network environment, S40 right network resource leak special attention to the specific variety of mobile phones, to open multiple connections at the same time is limited, we proposed here to be a test, it is no longer a cumbersome.

Official Website: http://www.forum.nokia.com/

S40 Platform Xiangjie: http://tech.sina.com.cn/mobile/n/2006-09-22/1053107637.shtml

S60 Platform

Nokia Smart Machine Platform for J2ME virtual machine. S40 is relatively speaking, S60 features supported are more and some more specific usage, such as access to system-related properties when one of them.

What is the JCP?

JCP (Java Community Process) is an open international organization, mainly by Java developers, and those who are authorized to composition, function is to develop and update the Java technology specification, Reference Implementation (RI), Technology Compatibility Pack (TCK). Java technology and JCP are the originators of both SUN computer company. However, JCP has been created by SUN in 1995, an informal Java, the process of evolution to the present hundreds of Java on behalf of the members from around the world work together to monitor the development of formal procedures for Java. JCP maintenance specifications, including J2ME, J2SE, J2EE, XML, OSS, JAIN and so on. Members can submit a JSR (Java Specification Requests), after the adoption of specific procedures to enter into the next version of the specification inside. All claim to meet the J2EE specification J2EE products (application servers, application software, development tools, etc.) must be provided by the organization through the TCK compatibility tests (need to purchase test kits), through the test, you need to pay J2EE trademark royalties. Two complete, that is, through the J2EE certification (Authorized Java Licensees of J2EE).

What is JSR?

JSR is a Java Specification Requests acronym, meaning that Java Specification Request. Refers to JCP (Java Community Process) proposed to add a standardized technical specifications of the official request. Anyone can submit JSR, the Java platform in order to add new API and services. JSR has become an important criterion for Java community.

The following is a list J2ME JSR specifications

Name

Content

JSR 118

MIDP 2.1 specification. MIDP defines the relevant interface, advanced UI, low-level UI, RMS, network-related APIs

JSR 82

Bluetooth interface defines the APIs associated

JSR135

Mobile Media API, defines the components of the development of multimedia-related APIs

JSR 172

1. A lightweight standard XML parser

2. Web Services Remote Call API

In which the JSR172 implementation lightweight XML parser is JAXP1.2 (Java API for XML Processing) a subset of. We can see WTK provides API to see j2me-xml class provides a total of only 12, which illustrates this lightweight XML parser is suitable for mobile phones that run on resource-constrained devices.

JSR 75

JSR 75 (PDA Optional Packages for the J2METM Platform) defines two optional packages:

PIM (The Personal Information Management) API, providing access to data of personal information generally, including contacts, calendar items, and Do.

FC (The FileConnection) APIs, provides the local file system access.

JSR 177

Security APIs

JSR 211

Content Hander content processing APIs, you can call this API to open the appropriate file, for example you can open the jar installation files, open the mp3.

JSR 239

Open GL @ ES. Is mainly used for graphics-related operations

JSR 179

Location APIs is mainly used for LBS services

JSR 180

SIP APIs

SIP is an application-layer signaling control protocol. Used to create, modify, and release of one or more of the participants in session. These sessions can be as if Internet multimedia conferencing, IP phones or multimedia distribution. Participants in the session can be multicast (multicast), mesh unicast (unicast) or a mixture of the two to communicate.

JSR 184

Mobile 3D Graphics APIs, 3D graphics development.

JSR 229

Mobile payment APIs

JSR 234

Multimedia support for advanced cell phones can support richer multimedia operation

JSR 238

Internationalization support for APIs

JSR 248

JSR 248: Mobile Service Architecture MSA Mobile Service Architecture.

MSA for CLDC specification defines the next generation of mobile phones Java platform, of course, is based on the J2ME platform for CLDC.

MSA for CLDC is designed to reduce the J2ME platform, the API division, for developers to define a high operational applications and service environment.

JTWI (Java Technology for Wireless Industry, JSR 185) defines a set of norms to force to achieve JTWI specification equipment must achieve certain JSR, for example, MIDP2.0, WMA, and MMAPI, etc.. MSA for CLDC can be considered as JTWI version 2 of which provides a highly centralized J2ME platform runtime environment.

Check JSR Support

Check JSR support of a simple two ways:

1. Is through System.getProperty ( "property_name") approach to determine in general if there is support for the relevant APIs, it will return a non-null string.

Detection code

System.getProperty (property_key);
public String getInfo (String info) (
if (info == null) (
return "";
) Else (
return info;
)
)

2. Through Class.forName (clase_name) approach.

private boolean hasClassExit (String aClassName) (
try (
Class.forName (aClassName);
return true;
) Catch (Exception e) (
return false;
)
)

The above code is relatively simple test, but also easy to understand, the key is those who supported JSR property name, or the APIs and writing style.

The following is part of the property name for reference purposes only.

System property

Description

Value

microedition.platform

Defined in CLDC 1.0 and CLDC 1.1.

microedition.encoding

Always returns ISO-8859-1.

microedition.configuration

Defined in CLDC 1.0 and CLDC 1.1.

microedition.profiles

Depends on the underlying implementation

microedition.locale *

JSR 37

Depends on the underlying implementation

microedition.commports

Depends on the underlying implementation

microedition.hostname

localhost

microedition.profiles

MIDP2.0

file.separator

File separator

Depends on the underlying implementation (/,)

microedition.pim.version

JSR 75

1.0

microedition.smartcardslots

JSR 177

Depends on the underlying implementation

microedition.location.version

JSR 179

1.0

microedition.sip.version

JSR 180

1.0

microedition.m3g.version

JSR 184

1.0

microedition.jtwi.version

JSR 185

1.0

wireless.messaging.sms.smsc

JSR 205

Depends on the underlying implementation

wireless.messaging.mms.mmsc

JSR 205

Depends on the underlying implementation

CHAPI-Version

JSR 211

JSR 211

Nokia some of the system parameters

com.nokia.network.access

Network parameters

pd - GSM

pd.EDGE - EDGE

pd.3G - 3G

pd.HSDPA - 3G

csd - GSM CSD / HSCSD

bt_pan - Bluetooth PAN network

wlan - WIFI

na - without any network

com.nokia.mid.dateformat

Date Format

Yy / mm / dd

com.nokia.mid.timeformat

Time Format

hh: mm

com.nokia.memoryramfree

Dynamic memory allocation

Note: S60 3rd edition does not support the

com.nokia.mid.batterylevel

Battery Status

com.nokia.mid.countrycode

City Code

com.nokia.mid.networkstatus

Network Working Status

com.nokia.mid.networkavailability

The network is active

com.nokia.mid.networkid

Network ID

Return two values

Network ID

Network referred to as

com.nokia.mid.networksignal

com.nokia.mid.cellid

Cellid

The base station ID information

com.nokia.mid.imei

Imei Number

Phone unique identification number

com.nokia.mid.imsi

Application Property

Application property value is in the application descriptor file or defined in the MANIFEST file, when we deploy the application when the application can be defined attributes. The following is a typical example JAD file content.

MIDlet-1: HttpWrapperMidlet, httpwrapper.HttpWrapperMIDlet

MIDlet-Jar-Size: 16315

MIDlet-Jar-URL: HttpWrapper.jar

MIDlet-Name: HttpWrapper

MIDlet-Vendor: Vendor

MIDlet-Version: 1.0

MicroEdition-Configuration: CLDC-1.0

MicroEdition-Profile: MIDP-1.0

Which-Locale: en

Which-Locale of which is the application attribute values, we can approach MIDlet members getAppProperty () to get it, the code snippet is as follows:

import javax.microedition.midlet .*;
public class MyMIDlet extends MIDlet (
private String suiteName;
private String which_locale;
public MyMIDlet () (
suiteName = getAppProperty ( "MIDlet-Name");
which_locale = getAppProperty ( "Which-Locale");
)
/ / Other code omitted here
)

Attribute value pairs is case sensitive, if the property value in the underlying systems, JAD file and the Manifest files are not defined, then will return Null.

Simple Demo

Here is a simple test environment code, experienced friend can be very easy to run up.

Snippet

/ **
* GetSysInfo
* /
private void getSysInfo () (
addInfo ( "Microedition Configuration:",
getInfo (System.getProperty ( "microedition.configuration ")));
addInfo ( "Microedition Profiles:",
getInfo (System.getProperty ( "microedition.profiles ")));
addInfo ( "microedition.jtwi.version:",
getInfo (System.getProperty ( "microedition.jtwi.version ")));
addInfo ( "microedition.platform:",
getInfo (System.getProperty ( "microedition.platform ")));
addInfo ( "microedition.locale:",
getInfo (System.getProperty ( "microedition.locale ")));
addInfo ( "default encoding:",
getInfo (System.getProperty ( "microedition.encoding ")));
addInfo ( "microedition.commports",
getInfo (System.getProperty ( "microedition.commports ")));
addInfo ( "microedition.hostname",
getInfo (System.getProperty ( "microedition.hostname ")));
/ / Microedition.smartcardslots
addInfo ( "microedition.smartcardslots",
getInfo (System.getProperty ( "microedition.smartcardslots ")));
addInfo ( "com.nokia.network.access",
getInfo (System.getProperty ( "com.nokia.network.access ")));
addInfo ( "com.nokia.mid.dateformat",
getInfo (System.getProperty ( "com.nokia.mid.dateformat ")));
addInfo ( "com.nokia.mid.timeformat",
getInfo (System.getProperty ( "com.nokia.mid.timeformat ")));
addInfo ( "com.nokia.memoryramfree",
getInfo (System.getProperty ( "com.nokia.memoryramfree ")));
addInfo ( "com.nokia.mid.batterylevel",
getInfo (System.getProperty ( "com.nokia.mid.batterylevel ")));
addInfo ( "com.nokia.mid.countrycode",
getInfo (System.getProperty ( "com.nokia.mid.countrycode ")));
addInfo ( "com.nokia.mid.networkstatus",
getInfo (System.getProperty ( "com.nokia.mid.networkstatus ")));
addInfo ( "com.nokia.mid.networksignal",
getInfo (System.getProperty ( "com.nokia.mid.networksignal ")));
addInfo ( "com.nokia.mid.networkid",
getInfo (System.getProperty ( "com.nokia.mid.networkid ")));
addInfo ( "com.nokia.mid.networkavailability",
getInfo (System.getProperty ( "com.nokia.mid.networkavailability ")));
addInfo ( "com.nokia.mid.cellid",
getInfo (System.getProperty ( "com.nokia.mid.cellid ")));
addInfo ( "com.nokia.mid.imei",
getInfo (System.getProperty ( "com.nokia.mid.imei ")));
addInfo ( "com.nokia.mid.imsi",
getInfo (System.getProperty ( "com.nokia.mid.imsi ")));
String [] timeZoneIDs = java.util.TimeZone.getAvailableIDs ();
StringBuffer timeZonesBuffer = new StringBuffer ();
for (int i = 0; i ";
) Else (
return info;
)
)
public void addInfo (String name, String value) (
iForm.append (new StringItem (name, value));
)

Snippet 2

public void collectInfos (TestClient midlet, Display display) (
try (
Class.forName ( "javax.microedition.media.control.VideoControl");
addInfo ( "MMAPI:", "yes");
addInfo ( "MMAPI-Version:", getInfo (System.getProperty ( "microedition.media.version")));
) Catch (ClassNotFoundException e) (
addInfo ( "MMAPI:", "no");
)
try (
Class.forName ( "javax.wireless.messaging.Message");
addInfo ( "WMAPI 1.1:", "yes");
try (
Class.forName ( "javax.wireless.messaging.MultipartMessage");
addInfo ( "WMAPI 2.0:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "WMAPI 2.0:", "no");
)
) Catch (ClassNotFoundException e) (
addInfo ( "WMAPI 1.1:", "no");
)
try (
Class.forName ( "javax.bluetooth.DiscoveryAgent");
addInfo ( "Bluetooth-API:", "yes");
try (
Class.forName ( "javax.obex.ClientSession");
addInfo ( "Bluetooth-Obex-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "Bluetooth-Obex-API:", "no");
)
) Catch (ClassNotFoundException e) (
addInfo ( "Bluetooth-API:", "no");
)
try (
Class.forName ( "javax.microedition.m3g.Graphics3D");
addInfo ( "M3G-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "M3G-API:", "no");
)
try (
Class.forName ( "javax.microedition.pim.PIM");
addInfo ( "PIM-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "PIM-API:", "no");
)
try (
Class.forName ( "javax.microedition.io.file.FileSystemRegistry");
addInfo ( "FileConnection-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "FileConnection-API:", "no");
)
try (
Class.forName ( "javax.microedition.location.Location");
addInfo ( "Location-API:", "yes");
) Catch (java.lang.Throwable e) (
addInfo ( "Location-API:", "no");
)
try (
Class.forName ( "javax.microedition.xml.rpc.Operation");
addInfo ( "WebServices-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "WebServices-API:", "no");
)
try (
Class.forName ( "javax.microedition.sip.SipConnection");
addInfo ( "SIP-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "SIP-API:", "no");
)
try (
Class.forName ( "com.nokia.mid.ui.FullCanvas");
addInfo ( "Nokia-UI-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "Nokia-UI-API:", "no");
)
try (
Class.forName ( "com.siemens.mp.MIDlet");
addInfo ( "Siemens-Extension-API:", "yes");
try (
Class.forName ( "com.siemens.mp.color_game.GameCanvas");
addInfo ( "Siemens-ColorGame-API:", "yes");
) Catch (ClassNotFoundException e) (
addInfo ( "Siemens-ColorGame-API:", "no");
)
) Catch (ClassNotFoundException e) (
addInfo ( "Siemens-Extension-API:", "no");
)
)

Schedule: attribute table

Table 1 MMAPI property

Property Name

Attribute the role of

supports.mixing

Phone support or otherwise on behalf of mixing (both play multiple Player), the return value is "true" or "false"

supports.audio.capture

Whether to support on behalf of mobile phone voice capture (recording), the return value is "true" or "false"

supports.video.capture

Whether to support on behalf of mobile phone video capture (video), the return value is "true" or "false"

supports.recording

Whether to support on behalf of mobile phone records (record), the return value is "true" or "false"

audio.encodings

Representative phone supports voice format, the return value format "encoding = audio / wav", number format, use at least one space between the interval to

video.encodings

On behalf of mobile phone supported video formats, the return value format "encoding = video/3gpp", number format, use at least one space between the interval to

video.snapshot.encodings

Use of mobile phones getSnapshot obtained on behalf of the video snapshot formats, the return value format "encoding = png", number format, use at least one space between the interval to

streamable.contents

Representative phone supports streaming media formats, return null mean not supporting the

Table 2 Wireless Messaging API Properties

Property Name

Attribute the role of

wireless.messaging.sms.smsc

When sending text messages on behalf of mobile phone short message service center number

Table 3FileConnection API

Property Name

Attribute the role of

fileconn.dir.photos

On behalf of mobile phone photos and other images stored in the directory, for example, "file: / / / c: / My files / Images /"

fileconn.dir.videos

On behalf of video stored on their phone directory, for example, "file: / / / c: / My files / Video clips /"

fileconn.dir.tones

Voices on behalf of the directory stored on their phone, for example, "file: / / / c: / My files / Tones /"

fileconn.dir.memorycard

On behalf of mobile phone memory card root directory. For example, "file: / / / d: /"

fileconn.dir.private

(Nokia S40 does not support)

On behalf of mobile phones in the MIDlet private working directory, for example, "file: / / / c: / System / MIDlets / [1015f294] / scratch"

fileconn.dir.photos.name

On behalf of mobile phone picture directory names, such as "Images"

fileconn.dir.videos.name

On behalf of mobile phone video directory names, such as "Video clips"

fileconn.dir.tones.name

On behalf of mobile phone voice directory names, such as the "Sound clips"

file.separator

Documents on behalf of the mobile phone separator, such as "/"

fileconn.dir.memorycard.name

Mobile phone memory card on behalf of the name, for example, "Memory card"

http://tech.ddvip.com/2009-03/1238123667112398.html

相关文章
  • J2ME software development of high portability 2010-03-29

    With the popularity of MTK, so that the current J2ME virtual machine on the market many brands, in addition to Sony Ericsson, Nokia S40, Moto, Samsung, LG and other major international brands of virtual machines, but there is a MTK, Spreadtrum built

  • Use Eclipse JEE + Mtj + Nokia S60 V3SDK J2ME application development environment to build 2010-10-14

    Use Eclipse JEE + Mtj + Nokia S60 V3SDK J2ME application development environment to build 2010-04-07 16:53 Under the Nokia S60 V3 J2ME application development, you need to build the official Nokia SDK provides environment. J2ME application developmen

  • Software development and progress of implementation of the project management control 2010-10-28

    Information technology and modern management science knowledge and the rapid development and rapid spread, making the government , enterprise IT applications, increasing demand for strong and harsh, but can not ignore the fact that it is "software pr

  • On the software development process from Java [turn] 2007-11-03

    After nearly a decade of development, Java is the most popular program on the planet development language that is no exaggeration. Java gives developers a high degree of freedom of choice, to show "Java Everywhere" charm and effectiveness. You h

  • Software development project implementation and progress of management control 2010-10-28

    Information technology and modern management science knowledge and the rapid development and rapid spread, making the government , enterprises are increasingly strong demand for IT applications and harsh, but can not ignore the fact that it is "softw

  • To the commercial software development engineers have a question 2009-03-26

    Questions are as follows: If your product has been sold out, but a lot of users (possibly thousands on ten thousand), how do you deal with your code to achieve as much as possible to meet the needs of different customers, but it will not take any imp

  • I insist, I do software development, I enjoy software development 2009-03-27

    Luck with the project manager for the outcome of the negotiations are, I leave the. Project manager gave me two choices to do software maintenance, and the other is away. I chose the second. Project manager give me the answer to say that I do not mee

  • Software Development Methods 2009-03-31

    Waterfall Development Method: This is an ideal state of development. All under the level based on job level. Once on the job level, the problems could not be delivered to the next level of working hours, the whole team are parked in it yes. Spiral de

  • What is Agile Software Development 2009-04-03

    Interaction between people are complex, and its effect has always been unpredictable, but it is the work of the most important aspects. - Tom DeMacro and Timothy Lister Agile Software Development Declaration: n individual and interactive process and

  • One of the most read books on software development management 2009-04-06

    Original See also: http://www.noop.nl/2008/06/top-100-best-software-engineering-books-ever.html 1 Steve McConnell Code Complete: A Practical Handbook of Software Construction 2 Elisabeth Freeman, etc. Head First Design Patterns 3 Steve McConnell Rapi

  • Worth reading the recent 50 software development and management books 2009-04-06

    Original See also: http://www.noop.nl/2009/03/top-50-new-software-development-books.html Title / Author (s) Release 1 Dreaming in Code: Two Dozen Programmers, Three Years, 4732 Bugs, and One Quest for Transcendent Software Scott Rosenberg 26-1-2007 2

  • Software development sunflower Baodian 2009-04-10

    Chinese martial arts novels of the National People's Congress are like to use to compare software development, but in actual combat martial arts, only sunflower is the most powerful book, and only mastered the sunflower canon that can be referred to

  • What kind of software development in order to enable us happy 2009-04-13

    Software development in the end are driven by what? Application software, and tools are not there is a lot different? A project are necessary for a clear line of thought, and the concept of the project objectives set up in line with the standards, an

  • Sunflower Baodian of software development 2009-04-14

    Chinese martial arts novels of the National People's Congress are like to use to compare software development, but in actual combat martial arts, only sunflower is the most powerful book, and only mastered the sunflower canon that can be referred to

  • What kind of software development in order to allow us happy 2009-04-14

    Software development in the end are driven by what? Application software, and tools are not there is a lot different? A project are necessary for a clear line of thought, and the concept of the project objectives set up in line with the standards, an

  • Software development model of the decoration articles 2009-04-20

    Software development model of the decoration articles N times the project has experienced the delay and disappointment, the regular reflection, why are we so? Why do we still do overtime every day? Why do we learn from a pile of advanced software dev

  • Easy software development -----( 1) goes beyond the process of iterative development 2009-04-25

    Recently being read "Head First Software Development" book 1, it is easy enjoy series books, language fluency, yet also witty and lively language. Incidentally, while you study English, in fact, the series of books could hang smooth, as long as

  • Software development in the easy rules 2009-05-03

    Read the John Maeda "Simple rules" , I have summed up the look of software development in 10 easy rules. 1) confidence No matter what, confidence is the most important. I have always believed in two ads language, are a Li Ning's "Anything i

  • Software development summary 2009-05-05

    Needs to give you some non-functional (or quality) requirements of the example? If customers require high performance, the use of extremely high degree of convenience and security, you will give him any suggestions? Can you give some to describe the

  • Software Development Process (CMMI / RUP / XP / MSF) are with non-? 2009-05-05

    Often see and hear everyone in the process of argument Agile, RUP and CMM software development process which better or what the process well, have their own reasons, the controversy was in fact ...... joy, there is no perfect process, there is no bet