Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Checking network strength in Java ME

From Wiki
Jump to: navigation, search

This code snippet demonstrates how to retrieve the current network strength.

Article Metadata
Code ExampleTested with
Devices(s): Nokia E70, Nokia N78, Nokia 701, Nokia Asha 305
Created: vltsoy (27 Nov 2008)
Last edited: hamishwillee (22 Jul 2013)



The code example retrieves the system property

If a network is available, the property will contain the string available. After that, the application reads the network strength from the property and displays it.

Note that in Series 40 platform only signed MIDlets under operator domain can retrieve this information.

Source file:

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
public class NetworkStrength extends MIDlet implements CommandListener{
private Display display;
private Form form;
// Commands.
private Command exitCommand;
private Command refreshCommand;
// Output fields.
private StringItem strength;
private StringItem availability;
* Constructor. Constructs the object and initializes displayables.

public NetworkStrength() {
form = new Form("Network strength.");
exitCommand = new Command("Exit", Command.EXIT, 2);
refreshCommand = new Command("Refresh", Command.OK, 1);
availability = new StringItem("Network status:", "");
strength = new StringItem("Network signal strength:", "\n --- ");
display = Display.getDisplay(this);
* From MIDlet.
* Called when the MIDlet is started.

public void startApp() {
// No implementation required.
* From MIDlet.
* Called to signal the MIDlet to enter the Paused state.

public void pauseApp() {
// No implementation required.
* From MIDlet.
* Called to signal the MIDlet to terminate.
* @param unconditional whether the MIDlet has to be unconditionally
* terminated

public void destroyApp(boolean unconditional) {
// No implementation required
* From CommandListener.
* Called by the system to indicate that a command has been invoked on a
* particular displayable.
* @param cmd the command that was invoked
* @param displayable the displayable where the command was invoked

public void commandAction(Command c, Displayable d) {
if (c == refreshCommand) {
} else if (c == exitCommand) {
* Called to check network availability and strength.

private void checkNetworkStatus() {
String available =
String signal = System.getProperty("");
//If network available.
if (available!=null && available.compareTo("available") == 0) {
} else {
availability.setText("\n unavailable \n");
strength.setText("Unable to retrieve current battery level.\n" +
"It's only available for signed midlets " +
"under operator domain.");


If a network is available, the MIDlet displays the current signal strength.

Supplementary material

The source file and executable application are available for download at Media:Checking network strength in

This page was last modified on 22 July 2013, at 11:03.
91 page views in the last 30 days.