免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 927 | 回复: 0
打印 上一主题 下一主题

MIDP Application Properties [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-11 21:27 |只看该作者 |倒序浏览

By
Eric Giguere
, April 11, 2005


E-mail
  



Print-friendly Version

  

Download
-->

A MIDlet, an application based on the Mobile Information Device Profile (MIDP), has access to two sets of runtime properties: system and application.  
The concept of system properties is actually defined by the Connected Limited Device Configuration (CLDC), on which the MIDP is based. The underlying platform sets the properties and the application can obtain their values but cannot change them. The set of system properties varies depending on what features are available on the platform - see the FAQ
"What are the defined J2ME system property names?"
for a partial list of common system properties. To read a system property the MIDlet invokes System.getProperty(), a static method.  
Application properties are obtained from the union of the attributes defined in the application descriptor and those in the MIDlet suite's manifest, part of the JAR file packaging. You set their values when you package the application for deployment. Consider a typical application descriptor:  
        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
To read an application property like the Which-Locale attribute in this descriptor, a MIDlet invokes MIDlet.getAppProperty(), a non-static, instance method. This example code obtains the name of the MIDlet suite by querying the MIDlet-Name property:  
import javax.microedition.midlet.*;
    public class MyMIDlet extends MIDlet {
        private String suiteName;
        public MyMIDlet(){
            suiteName = getAppProperty( "MIDlet-Name" );
            ... // more stuff
        }
        ... // etc.
    }
Property names are case-sensitive. If a property is not defined by either the application descriptor or the manifest, null is returned. If the same property is defined differently in the application descriptor and the manifest, the conflict is resolved in one of two ways: If the MIDlet is a trusted application based on MIDP 2.0, the system simply won't install the application. Otherwise, the value in the descriptor overrides the value in the manifest.  
Application properties are particularly useful when descriptors are generated dynamically. For example, you can embed a registration key in the descriptor that the application will read and pass back to a registration server the first time it's run, without having to recompile or repackage the application itself. Don't stuff a lot of data in the descriptor, though, because some platforms limit the descriptor size. Use application properties wherever you'd use a standard Java properties file in a J2SE application.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/38418/showart_298895.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP