Problem Running System Wide App
Please Login to Remove!
I'm trying to create a system wide application. I've got the menu option to appear on most menus but when I try to execute the application the program throws an exception... I'm compiling and running this app as a CLDC application that starts at system startup. Any ideas?
package com.thesolutioncafe.blackberry.test;
import net.rim.device.api.ui.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.Dialog;
import net.rim.blackberry.api.menuitem.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
public class BBInit extends Application
{
private static long ID = 0xe1e5ac072dc45f40L;
public static void main(String[] args)
{
BBInit theApp = new BBInit();
theApp.enterEventDispatcher();
}
public BBInit()
{
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MEN UITEM_SYSTEM, new BBMenuItem());
}
private static class BBMenuItem extends ApplicationMenuItem {
BBMenuItem() {
super(20);
}
public String toString() {
return "Test Menu Item";
}
public Object run(Object context) {
System.out.println(context);
new BBUI().enterEventDispatcher();
return null;
}
}
final static class BBUI extends UiApplication
{
public BBUI()
{
pushScreen(new BBUIScreen());
}
}
final static class BBUIScreen extends MainScreen
{
public BBUIScreen()
{
super(DEFAULT_MENU | DEFAULT_CLOSE);
setTitle(new LabelField("BBUIScreen", LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));
add(new RichTextField("Test"));
}
public boolean onClose()
{
Dialog.alert("BBUIScreen Complete");
System.exit(0);
return true;
}
public boolean keyChar(char key, int status, int time) {
//intercept the ESC key - exit the app on its receipt
boolean retval = false;
switch (key) {
case Characters.ESCAPE:
onClose();
retval = true;
break;
}
return retval;
}
}
}
|