J2ME系统属性

这两天有点不爽,暂时不对《无聊的JAVA》更新了。现在写点无聊的东西,J2ME开发中系统相关属性的获得,包括对API和OP的支持检测,屏幕的属性,内存属性等,有兴趣可以看看。

通过System.getProperty(String key)获得:

  • microedition.platform 平台名称,如j2me
  • microedition.configuration CLDC或CDC版本,如CLDC-1.0
  • microedition.profiles MIDP版本,如MIDP-1.0
  • microedition.encoding 默认的系统编码,如GBK
  • microedition.locale 默认的区域设置,如zh-CN
  • microedition.media.version MMAPI的版本,如1.1
  • supports.mixing 是否支持混音,如true
  • supports.audio.capture 是否支持音频捕获,如true
  • supports.video.capture 是否支持视频捕获,如true
  • supports.recording 是否支持录音,如true
  • audio.encodings 音频编码格式,如encoding=pcm encoding=pcm&rate=8000&bits=8&channels=1
  • video.snapshot.encodings 拍摄图片的编码格式,如encoding=jpeg encoding=png
  • streamable.contents 支持的流媒体格式,如audio/x-wav
  • wireless.messaging.sms.smsc 返回SMS的服务中心,如+8613800010000
  • wireless.messaging.mms.mmsc 返回MMS的服务中心,如http://mmsc.monternet.com
  • microedition.m3g.version 返回Mobile 3D的版本,如1.0
  • 注意下面的使用需要做一些初始化工作(怎么使用,下次再说)还有就是呢属性是区分大小写和空格的

  • bluetooth.api.version 返回蓝牙API的版本,如1.0
  • microedition.io.file.FileConnection.version 返回FileConnection的版本,如1.0
  • microedition.pim.version 返回PIM的版本,如1.0

使用getAppProperty()方法获得的属性
这些属性都是定义在JAD中(MEB-INF文件中也有,不过优先级比jad文件中要低),怎么使用我就不多说了吧,getAppProperty((”MIDlet-Name”)获得midlet的名字之类推了.

屏幕显示相关的属性
主要使用Display的实例Display.getInstance()获得,来获得相关属性

  • isColor() 检测是否为彩色
  • display.numColors() 彩色位数
  • numAlphaLevels() 绘制可用的透明度

其他

  • Runtime类的totalMemory() 总的内存
  • freeMemory() 可用的内存

Tags: ,

No Comments

(Required)
(Required, will not be published)

Powered by WP Hashcash