Nayade
04-14-2005, 07:27 AM
Hello and sorry for my english :oops:
I add an ApplicationMenuItem to a Blackberry Contacts application, but when I click in this menu item I have an error:
"application already running in this process"
This the code of the Blackberry example:
package com.rim.samples.docs.menuitem;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.Dialog.*;
import net.rim.blackberry.api.menuitem.*;
import javax.microedition.pim.*;
import com.rim.samples.docs.contactsdemo.*;
public final class DemoAppMenuItem extends Application {
private static long ID = 0x7cab1e23b72a0033L;
//com.rim.samples.docs.menuitem
public static void main(String[] args) {
DemoAppMenuItem app = new DemoAppMenuItem();
app.enterEventDispatcher();
}
DemoAppMenuItem() {
ApplicationMenuItemRepository amir =
ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSCARD_VIEW,
new SampleMenuItem());
}
private static class SampleMenuItem extends ApplicationMenuItem {
SampleMenuItem() {
super(20);
}
public String toString() {
return "Open the Contacts Demo";
}
public Object run(Object context) {
Contact c = (Contact)context; //an error if this doesn't work
if ( c != null ) {
new ContactsDemo().enterEventDispatcher();
} else {
throw new IllegalStateException( "Context is null, expected a Contact instance");
}
net.rim.device.api.ui.component.Dialog.alert("Viewing an email message in the email view");
return null;
}
}
}
And the ContactsDemo is a library project and the class extends UiApplication
Thanks a lot!
I add an ApplicationMenuItem to a Blackberry Contacts application, but when I click in this menu item I have an error:
"application already running in this process"
This the code of the Blackberry example:
package com.rim.samples.docs.menuitem;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.Dialog.*;
import net.rim.blackberry.api.menuitem.*;
import javax.microedition.pim.*;
import com.rim.samples.docs.contactsdemo.*;
public final class DemoAppMenuItem extends Application {
private static long ID = 0x7cab1e23b72a0033L;
//com.rim.samples.docs.menuitem
public static void main(String[] args) {
DemoAppMenuItem app = new DemoAppMenuItem();
app.enterEventDispatcher();
}
DemoAppMenuItem() {
ApplicationMenuItemRepository amir =
ApplicationMenuItemRepository.getInstance();
amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSCARD_VIEW,
new SampleMenuItem());
}
private static class SampleMenuItem extends ApplicationMenuItem {
SampleMenuItem() {
super(20);
}
public String toString() {
return "Open the Contacts Demo";
}
public Object run(Object context) {
Contact c = (Contact)context; //an error if this doesn't work
if ( c != null ) {
new ContactsDemo().enterEventDispatcher();
} else {
throw new IllegalStateException( "Context is null, expected a Contact instance");
}
net.rim.device.api.ui.component.Dialog.alert("Viewing an email message in the email view");
return null;
}
}
}
And the ContactsDemo is a library project and the class extends UiApplication
Thanks a lot!