PDA

View Full Version : wtkrapc -> rapc ant task


bdowling
02-05-2007, 04:18 AM
Hi,

I'm building a BlackBerry application in Eclipse. Currently I'm using the Antenna wtkrapc build task below, which takes a JAR archive of all the class files, and a JAD file as arguments:


<target name="rapc" description="RIM COD Compiler" depends="package">
<wtkrapc
quiet="true"
midlet="false"
jadfile="${jadfile}"
source="${final.jar}"
codename="${codename}"
import="${net_rim_api.jar}"
destdir="output/tocod/"/>
</target>


The application auto-runs on the BlackBerry, which is achieved by specifying RIM-MIDlet-Flags-1: 3 in the JAD file.

The project has now got to the point where I need to specify an alternate entry point, which is not auto-run and requires a custom icon. As far as I'm aware this cannot be achieved with the wtkrapc task, and I must use the rapc task instead. I've read through this excellent thread: Building without JDE... - BlackBerryForums.com : Your Number One BlackBerry Community (http://blackberryforums.com/developer-forum/23616-building-without-jde.html) but I'm still not sure how I can convert my current wtkrapc task to a rapc task. Where do you specify the input files etc?

Any help would be greatly appreciated!

TIA, Ben

bdowling
02-05-2007, 05:02 AM
I'm also going to need to synchronise the application data with the desktop. The dev guide talks about setting 'arguments passed field to init' using the JDE. How can this be done using ant?

Thanks again, Ben

bdowling
02-05-2007, 09:53 AM
I've now managed to convert the wtkrapc task to a rapc task:

<rapc jdehome="${jdehome}">
<workspace src="BB.jdw" build="true" update="true">
<cldc src="cldc_project.jdp" title="${codename}" vendor="Telnic" version="0.1" description="Application For BlackBerry OS" arguments="" systemmodule="true" runonstartup="true" startuptier="7" output="${codename}" options="-quiet" update="true" build="true">
<files dir=".">
<include name="src/**/*.*" />
</files>
</cldc>

</workspace>
</rapc>


Now I need to add the alternate entry point. I know I can use the cldcentrypoint tag, but how do I specify which class to use as the alternate entry point?

Ben

Skipper_Joe
02-06-2007, 09:53 AM
As far as I know, you can't have 2 entry points (main() methods) in 1 BlackBerry application.
However you can check in your main method if application is called on startup. I didn't try it myself yet, but I found next code snippet in blackberrytools project:


public static void main(String[] args) {

try {
// If we are starting up then register our replyto menu items
// otherwise we should display the BBReply configuration screen
if (ApplicationManager.getApplicationManager().inStartup()) {
registerMenuItem();
CorrectorStringPattern stringPattern = new CorrectorStringPattern();
StringPatternRepository.addPattern(stringPattern);
RuntimeStore.getRuntimeStore().put(CorrectorActiveFieldCookie.ID,
new CorrectorActiveFieldCookieFactory());
} else {
System.out.println("*** Start BBCorrector GUI application");
BBCorrector bbcorrector = new BBCorrector();
bbcorrector.enterEventDispatcher();
}
} catch (Exception e) {
System.out.println("*** Error: " + e.getMessage());
}

}


see SourceForge.net Repository - [blackberrytools] View of /bbcorrector/src/org/bbcorrector/BBCorrector.java (http://blackberrytools.cvs.sourceforge.net/blackberrytools/bbcorrector/src/org/bbcorrector/BBCorrector.java?revision=1.1.1.1&view=markup)

bdowling
02-06-2007, 11:47 AM
The JDE allows you to specify alternate entry points.

Basically what I have is a main application that I want to run at startup, that adds menus to the address book.

I also want an Icon to launch the application separately from the menu items. Therefore I have one class with a main that registers the menu items, and one that launches an application.

I could have two COD files, but the classes are shared, so it seems a waste of space. It's also a pain to have to install two COD files, when essentially there is one application.

Skipper_Joe
02-06-2007, 12:45 PM
Hi, Ben!

Can you describe how you can define alternate entry points in JDE? I find "alternate entry point" dropdown in Project Properties, but it is always disabled and I don't know how to use it.

I think solution which I proposed above, works for your needs. main() method in provided code snippet works in both cases: when user runs application clicking icon on Home screen and when device starts up.
ApplicationManager.inStartup() method allows to differentiate these 2 cases in runtime and implement different behavior for each cases.

I just tried it myself - it works for me.

Andrey

bdowling
02-07-2007, 05:23 AM
Hi Andrey,

I have no idea how you specify the alternate entry point in the JDE (I'm using eclipse), but I have read about it in the BlackBerry docs. I may have misunderstood the purpose of it.

I gave the sample code a go and it didn't work for me at first. After I changed my application from a system module to a non-system module it worked perfectly though!!

Thanks, Ben