簡單的Demo
下面是簡單的測試環境的代碼,有經驗的朋友可以很容易就就跑起來。
代碼片段
/**
* 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 < timeZoneIDs.length; i++) {
timeZonesBuffer.append(timeZoneIDs[i]).append('\n');
}
addInfo( "Total memory:",
Long.toString(Runtime.getRuntime().totalMemory()) + " bytes");
addInfo( "Free memory:",
Long.toString(Runtime.getRuntime().freeMemory()) + " bytes");
addInfo( "Available TimeZones:", timeZonesBuffer.toString());
addInfo( "Default TimeZone:", Java.util.TimeZone.getDefault().getID());
addInfo( "com.siemens.mp.lcdui.Image", hasClassExit("com.sIEmens.mp.lcdui.Image") + "");
addInfo( "com.motorola.phonebook.PhoneBookRecord", hasClassExit("com.motorola.phonebook.PhoneBookRecord") + "");
addInfo( "com.motorola.Dialer", hasClassExit("com.motorola.Dialer") + "");
addInfo( "com.jblend.util.Case", hasClassExit("com.jblend.util.Case") + "");
addInfo( "com.samsung.util.AudioClip", hasClassExit("com.samsung.util.AudioClip") + "");
addInfo( "com.mot.iden.multimedia.Lighting", hasClassExit("com.mot.iden.multimedia.Lighting") + "");
}
private boolean hasClassExit(String aClassName) {
try {
Class.forName(aClassName);
return true;
} catch (Exception e) {
return false;
}
}
public String getInfo(String info) {
if (info == null) {
return "<unknown>";
} else {
return info;
}
}
public void addInfo(String name, String value) {
iForm.append(new StringItem(name, value));
}
代碼片段2
public void collectInfos(TestClIEnt midlet, Display display) {附表:屬性表
表1 MMAPI屬性
屬性名稱
屬性作用
supports.mixing
代表手機是否支持混音(同時播放多個Player),返回值為“true”或“false”
supports.audio.capture
代表手機是否支持聲音捕獲(錄音),返回值為“true”或“false”
supports.video.capture
代表手機是否支持視頻捕獲(錄像),返回值為“true”或“false”
supports.recording
代表手機是否支持記錄(record),返回值為“true”或“false”
audio.encodings
代表手機支持的聲音格式,返回值格式為“encoding=audio/wav”,多個格式之間使用至少一個空格進行間隔
video.encodings
代表手機支持的視頻格式,返回值格式為“encoding=video/3gpp”,多個格式之間使用至少一個空格進行間隔
video.snapshot.encodings
代表手機使用getSnapshot方法獲得的視頻快照格式,返回值格式為“encoding=png”,多個格式之間使用至少一個空格進行間隔
streamable.contents
代表手機支持的流媒體格式,返回null代表不支持
表2 Wireless Messaging API屬性
屬性名稱
屬性作用
wireless.messaging.sms.smsc
代表手機發送短信時的短信服務中心號碼
表3FileConnection API
屬性名稱
屬性作用
fileconn.dir.photos
代表手機中存儲照片和其它圖片的目錄,例如“file:///c:/My files/ Images /”
fileconn.dir.videos
代表手機中存儲視頻的目錄,例如“file:///c:/My files/Video clips/”
fileconn.dir.tones
代表手機中存儲聲音的目錄,例如“file:///c:/My files/Tones/”
fileconn.dir.memorycard
代表手機中存儲卡的根目錄。例如“file:///d:/”
fileconn.dir.private
(Nokia S40不支持)
代表手機中MIDlet的私有工作目錄,例如“file:///c:/System/MIDlets/[1015f294]/scratch”
fileconn.dir.photos.name
代表手機中圖片目錄的名稱,例如“Images”
fileconn.dir.videos.name
代表手機中視頻目錄的名稱,例如“Video clips”
fileconn.dir.tones.name
代表手機中聲音目錄的名稱,例如“Sound clips”
file.separator
代表手機中的文件分隔符,例如“/”
fileconn.dir.memorycard.name
代表手機中存儲卡的名稱,例如“Memory card”