×
Namespaces

Variants
Actions

Getting Cell ID in Java ME

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Code ExampleTested with
Devices(s): Nokia 701, Nokia Asha 305
CompatibilityArticle
Created: jarmlaht (14 May 2008)
Last edited: hamishwillee (22 Jul 2013)

Contents

Overview

This code snippet demonstrates how to get the mobile cell ID by using Nokia system properties in Series 40 and S60 devices. Note that a different system property is used to get the cell ID in Series 40 and S60 devices:

Platform Version Security Domain System property
Series 40 3rd Edition, FP1 up to Series 40 5th Edition Manufacturer / Operator
System.getProperty("Cell-ID")
Series 40 5th Edition, FP1 up to Series 40 6th Edition FP1 Manufacturer / Operator
System.getProperty("com.nokia.mid.cellid")
S60 3rd Edition, FP2 (or newer) Untrusted 3rd party
System.getProperty("com.nokia.mid.cellid")
Series 40 Developer Platform 1.0 (or newer) Untrusted 3rd party
System.getProperty("com.nokia.mid.cellid")

Note.pngNote: Signing in the manufacturer domain practically means that the property is inaccessible to 3rd party developers. Please ensure that your device belongs to a platform where the system property is available in the untrusted 3rd party domain

Source

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class CellIDMIDlet extends MIDlet implements CommandListener {
private Form form;
private Command exitCommand;
private String old_cell_id; // Old cell id property for some Series 40 devices
private String new_cell_id; // New cell id property for the latest Series 40 and Symbian devices
 
public void startApp() {
form = new Form("Getting Cell ID");
old_cell_id = System.getProperty("Cell-ID");
new_cell_id = System.getProperty("com.nokia.mid.cellid");
form.append("Old System Property: " + old_cell_id + "\n");
form.append("New System Property: " + new_cell_id);
exitCommand = new Command("Exit", Command.EXIT, 1);
form.setCommandListener(this);
form.addCommand(exitCommand);
Display.getDisplay(this).setCurrent(form);
}
 
public void pauseApp() {
}
 
public void destroyApp(boolean unconditional) {
}
 
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) this.notifyDestroyed();
}
}

Postconditions

When the MIDlet is run in either a Series 40 or S60 device, a cell ID should be shown on the Form (one will have a numeric value and another will have 'null').

See also

Java ME System properties

This page was last modified on 22 July 2013, at 14:41.
242 page views in the last 30 days.