程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> J2ME >> MIDP手機利用程序的屬性先容

MIDP手機利用程序的屬性先容

編輯:J2ME
MIDlet是在MIDP中提出的一種利用程序模型,目前在J2ME中利用最為廣泛。本文將重要先容MIDP利用程序的屬性標題。讀者可以參考MIDP Application PropertIEs

  MIDlet可以拜訪兩種運行時的屬性值:系統和利用程序的。

  系統屬性的概念是在CLDC(Connected Limited Device Configuration)中定義的,屬性值被寫進底層的系統,我們可以讀取它們但是不能修正這些屬性值。假如你想讀取一個系統屬性值那麼你可以應用System類的靜態方法System.getProperty()來讀取。經常有網友會詢問如何讀取手機號碼或者IMEI號碼,實在這些你應當參考具體機型的開發文檔。各個廠商的實現都是不一樣的。為了讓大家查找方便這裡列出在J2ME中定義的系統屬性值,假如你的手機支撐相干的JSR,那麼就可以通過上述方法取得屬性值。

JSR

 

Property Name

 

Default Value1

 

30

 

microedition.platform

 

null

 

 

microedition.encoding

 

ISO8859_1

 

 

microedition.configuration

 

CLDC-1.0

 

microedition.profiles

 

null

 

37

 

microedition.locale

 

null

 

 

microedition.profiles

 

MIDP-1.0

 

75

 

microedition.io.file.FileConnection.version

 

1.0

 

 

file.separator

 

(impl-dep)

 

 

microedition.pim.version

 

1.0

 

118

 

microedition.locale

 

null

 

 

microedition.profiles

 

MIDP-2.0

 

 

microedition.commports

 

(impl-dep)

 

 

microedition.hostname

 

(impl-dep)

 

120

 

wireless.messaging.sms.smsc

 

(impl-dep)

 

139

microedition.platform

 

(impl-dep)

 

 

microedition.encoding

 

ISO8859-1

 

 

microedition.configuration

 

CLDC-1.1

 

 

microedition.profiles

 

(impl-dep)

 

177

 

microedition.smartcardslots

 

(impl-dep)

 

179

 

microedition.location.version

 

1.0

180

 

microedition.sip.version

 

1.0

 

184

 

microedition.m3g.version

 

1.0

 

185

 

microedition.jtwi.version

 

1.0

 

195

 

microedition.locale

 

(impl-dep)

 

 

microedition.profiles

 

IMP-1.0

 

205

 

wireless.messaging.sms.smsc

 

(impl-dep)

 

205

 

wireless.messaging.mms.mmsc

 

(impl-dep)

 

 


      利用程序屬性值是在利用程序描寫符文件或者MANIFEST文件中定義的(其中MANIFEST文件是打包在jar文件中的),當我們安排利用程序的時候會定義利用程序屬性。比如下面是一個典范的jad文件內容:

 MIDlet-1: HttpWrapperMidlet,,httpwrapper.HttpWrapperMIDlet
 MIDlet-Jar-Size: 16315
 MIDlet-Jar-URL: HttpWrapper.jar
 MIDlet-Name: HttpWrapper
 MIDlet-Vendor: Vendor
 MIDlet-Version: 1.0
 MicroEdition-Configuration: CLDC-1.0
 MicroEdition-Profile: MIDP-1.0
 Which-Locale: en

  其中Which-Locale就是利用程序屬性值,我們可以通過MIDlet的成員方法getAppProperty()來得到它,代碼片段如下:


 import Javax.microedition.midlet.*;

 public class MyMIDlet extends MIDlet {
  private String suiteName;

  public MyMIDlet(){
   suiteName = getAppProperty( "MIDlet-Name" );
   ... // more stuff
  }

  ... // etc.
 }

  屬性值是大小寫敏感的,假如屬性值在系統,jad文件和manifest文件中都沒有定義的話,那麼將返回null。假如在jad文件和manifest文件中定義了同樣的屬性值,那麼會呈現如下兩種情況:假如利用程序是MIDP2.0種的信任利用程序,那麼AMS將會拒盡安裝。否則在jad文件中的屬性值會籠罩manifest中的值。 

  在jad文件中應用屬性值有必定的利益,假如你需要更改一些數據而又不想重新編譯代碼、打包的話,那麼你可以在jad中定義一些屬性值。這樣可以配置你的利用程序,想想是不是和你在J2SE利用中應用屬性文件類似。但是不要在jad文將中定義大批的數據,由於許多設備都是對jad文件的大小有限制的。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved