我有一个使用J2ME Polish从命令行(ANT)构建的应用程序。因此,此应用程序是通过build.xml定义的,而不是来自Blackberry JDE项目文件。
我需要做的是让这个应用程序自动启动。一旦应用程序第一次运行(example),这很容易做到。但是,这确实需要用户手动运行应用程序(我想避免)。
JDE提供了可以检查以启用自动启动的选项,以及ANT:
<cldc runonstartup=="true"...
会做的伎俩。问题是,如何将其集成到波兰语中(即波兰语build.xml,也是为其他平台构建的)?
任何人都知道JDE中的自动启动选项实际上做了什么/它改变了什么?
答案 0 :(得分:1)
因此,遗憾的是,改变J2ME-Polish源代码的方法就是这样!正如本bug report中所述,J2ME波兰语构建框架(版本2.1.4)未将RIM-MIDlet-Flags-x JAD属性传递给RAPC。
更改相对简单 - 仅传递RIM-MIDlet-Flags-1值(如果在JAD中定义),否则将其设置为零(如原始2.1.4源所示)。
差异(来自2.1.4)来源:
Index: /enough-polish-build/source/extensions/de/enough/polish/blackberry/JarToCodFinalizer.java
===================================================================
--- /enough-polish-build/source/extensions/de/enough/polish/blackberry/JarToCodFinalizer.java (revision 315)
+++ /enough-polish-build/source/extensions/de/enough/polish/blackberry/JarToCodFinalizer.java (revision 316)
@@ -36,6 +36,7 @@
import java.util.Calendar;
import java.util.Locale;
import java.util.Map;
+import java.util.List;
import java.util.Properties;
import org.apache.tools.ant.BuildException;
@@ -185,6 +186,13 @@
}
}
File iconFile = null;
+ Map jadProperties;
+ try {
+ jadProperties = FileUtil.readPropertiesFile( jadFile, ':' );
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException("Unable to read JAD file " + e.toString() );
+ }
if (mainClassName != null) {
try {
/*
@@ -230,12 +238,26 @@
"MicroEdition-Configuration: CLDC-1.1",
//"MIDlet-1: Demo," + iconUrl + ",",
"MIDlet-1: " + env.getVariable("MIDlet-Name") + "," + iconUrl + ",",
- //"MIDlet-Icon: " + iconUrl,
- "RIM-MIDlet-Flags-1: 0"
+ //"MIDlet-Icon: " + iconUrl
};
+ /* Ensure that if RIM-MIDlet-Flags is defined in the JAD, it is
+ * passed on to RAPC to create the COD file.
+ * See https://developer.berlios.de/bugs/?func=detailbug&group_id=1246&bug_id=16901
+ * for details.
+ */
+ ArrayList newEntriesList = new ArrayList(Arrays.asList(newEntries));
+ final String flagsKey = "RIM-MIDlet-Flags-1";
+ String flagString = (String)jadProperties.get(flagsKey);
+ if (flagString == null) {
+ flagString = "0";
+ }
+ flagString = flagString.trim();
+ System.out.println("JarToCodFinalizer setting " + flagsKey + ": " + flagString);
+ newEntriesList.add(flagsKey+ ": " + flagString);
+
File rapcFile = new File( jadFile.getParent(), codName + ".rapc");
- FileUtil.writeTextFile( rapcFile, newEntries );
+ FileUtil.writeTextFile( rapcFile, newEntriesList );
} catch ( IOException e ) {
// this shouldn't happen
e.printStackTrace();
@@ -367,7 +389,6 @@
// now rewrite JAD file so that it is ready for OTA download:
// (first backup JAD file:)
//FileUtil.copy(jadFile, new File(jadFile.getParent(), jadFile.getName() + ".bak") );
- Map jadProperties = FileUtil.readPropertiesFile( jadFile, ':' );
Object[] keys = jadProperties.keySet().toArray();
for (int i = 0; i < keys.length; i++) {
String key = (String) keys[i];
答案 1 :(得分:0)
另一位优秀的用户:)
在第二篇文章中查看BB个论坛。然后使用我们对polish和jad attributes
的了解将此添加到build.xml的jad部分
<jad>
<attribute name="RIM-MIDlet-Flags"
value="1"
if="polish.vendor == BlackBerry" />
</jad>
我没有测试过这个,但逻辑似乎是有效的:)让我知道它是否有效。