×
Namespaces

Variants
Actions
Revision as of 06:09, 19 November 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

在Java ME中取得Cell ID

From Nokia Developer Wiki
Jump to: navigation, search
WP Metro Icon Chinese.png
Article Metadata

兼容于
文章
翻译:
最后由 hamishwillee 在 19 Nov 2013 编辑

Contents

概論

這個程式碼描述在S40及S60系列的機器上如何使用Nokia-proprietary的系統屬性取得手機的cell ID,注意在不同系列的機器上需使用不同的系統屬性:

Series 40 3rd Edition, FP1 (或較新的):
System.getProperty("Cell-ID")
S60 3rd Edition, FP2 (或較新的):
System.getProperty("com.nokia.mid.cellid")

注意: 在S40機器上MIDlet需要製造商或運銷區域的簽名,否則這個屬性會是空值,S60的機上不需要簽名。

原始碼

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class CellIDMIDlet extends MIDlet implements CommandListener {
private Form form;
private Command exitCommand;
private String S40_cell_id; // Series 40 cell id property
private String S60_cell_id; // S60 cell id property
 
public void startApp() {
form = new Form("Getting Cell ID");
S40_cell_id = System.getProperty("Cell-ID");
S60_cell_id = System.getProperty("com.nokia.mid.cellid");
form.append("Series 40 devices: " + S40_cell_id + "\n");
form.append("S60 devices: " + S60_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();
}
}

後處理

當MIDlet在S40或S60系列的機器上執行時,cell ID會顯示在表單上(一個有數值另一個有'null')。

另見

Java ME系統屬性


相关链接

This page was last modified on 19 November 2013, at 06:09.
117 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×