Namespaces
Variants
Actions
Revision as of 08:57, 18 September 2012 by hamishwillee (Talk | contribs)

How to check if a specific API is supported in Java ME

Jump to: navigation, search
MultiMediaTile.png
SignpostIcon Gear 52.png
SignpostIcon Code 52.png
Article Metadata

Code Example
Tested with
Devices(s): Nokia N95 8GB, Nokia 701, Nokia Asha 305

Compatibility
Platform(s): Series 40, Symbian

Article
Keywords: java.lang.System, javax.microedition.lcdui.Alert, javax.microedition.lcdui.AlertType, java.lang.System.getProperty()
Created: tapla (09 May 2008)
Last edited: hamishwillee (18 Sep 2012)

Contents

Overview

This code snippet demonstrates how to check whether a specific Java ME API is supported on the device and also what version is supported. In this snippet, the API to be checked is the Wireless Messaging API.

Note.png
Note: The method System.getProperty() can also be used for obtaining several other properties than API versions. See Getting System properties in MIDP for a list of possibilities.

Source

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
String wmVersion = System.getProperty("wireless.messaging.version");
if (wmVersion != null) {
// Wireless messaging is supported. Inform the user.
Alert alert = new Alert("Supported",
"Wireless messaging is supported. Version is: " + wmVersion,
null, AlertType.INFO);
Display.getDisplay(this).setCurrent(alert);
} else {
// Wireless messaging is not supported. Inform the user.
Alert alert = new Alert("Not supported",
"Wireless messaging is not supported.", null,
AlertType.INFO);
Display.getDisplay(this).setCurrent(alert);
}

Postconditions

The MIDlet displays an alert which shows whether the Wireless Messaging API is supported and if it is, which version is supported.

See also

273 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved