Welcome to the Official BlackBerry® Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Developer
New Developer
flx
Posts: 2
Registered: 09-21-2009

Custom Menu showing up in simulator but not the actual device

I have developed a simple program to add a custom menu to the email application. The program works in simulator. The custom menu shows up in the email application and the action from the menu works. However, when I install the application in an actual device OTA, even though the device indicates the application has been installed successfully and shows up on the application list, but I don't see any menu in the email application. I also tried to add the menu to other application but it does not show up either. I am using JDE 4.5.0.7, default simulator for testing, and 8900 as the actual device for testing. I signed the application with RIM Blackberry Apps API (According to JDE this is the only one required), RIM Runtime API (not required), and RIM Crypto API (Optional).

 

I know it should work but I just can't make it work. I have searched the forum but can't seem to find out why I have this problem. Please let me know if there is anything I did that is incorrect. Much appreciated. I have inserted the code below:

 

 

public final class Demo extends Application { Demo() { try { ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance(); ApplicationMenuItem menu = new DemoMenuItem(); ApplicationDescriptor app = ApplicationDescriptor.currentApplicationDescriptor(); amir.addMenuItem( ApplicationMenuItemRepository.MENUITEM_EMAIL_VIEW , menu, app ); } catch( Throwable t ) { //ControlledAccessException thrown if access is denied accessing the location Dialog.alert( "Unable to initialize Demo " + t.toString() ); } } private static class DemoMenuItem extends ApplicationMenuItem { private Address[] addresses = null; DemoMenuItem() { super( 20 ); try { addresses = new Address[]{ new Address( "demo@demo.com", "Demo" ) }; } catch( Throwable t ) { System.out.println( "Unable to create application menu" ); } } public String toString() { return "Demo"; } public Object run ( Object aMessage ) { if ( aMessage instanceof Message ) { Message emailMessage = (Message)aMessage; emailMessage = emailMessage.forward(); try { emailMessage.addRecipients( Message.RecipientType.TO, addresses ); Transport.send( emailMessage ); } catch( Throwable t ) { t.printStackTrace(); System.out.println( "Unable to send message" ); } return emailMessage; } else { throw new IllegalStateException( "Expected an email object" ); } } } public static void main ( String[] args ) { Demo app = new Demo(); app.enterEventDispatcher(); }}

 

 

Please use plain text.
Developer
RexDoug
Posts: 4,649
Registered: 07-21-2008

Re: Custom Menu showing up in simulator but not the actual device

Just a guess, but I think you are probably hitting a controlled-access violation (ApplicationPermissions).

 

If the menu uitem is being added from in the startup context (not the event thread), then you will never see your exception dialog.

 

Did you pull the event log form the device and look for exceptions?

 

Also, try changing the dialog to a System.out.println() and attach the device to the debugger (you should see your text in the JDE output window).

 

One further suggestion: use ApplicationPermissionsManager to detect what the permissions are, and use this mechanism to set the correct permissions and prompt the user to accept them.

 

Please use plain text.
New Developer
New Developer
flx
Posts: 2
Registered: 09-21-2009

Re: Custom Menu showing up in simulator but not the actual device

Thanks for the information. That is what I suspect but I thought I set to grant all permissions but will double check that again and will also try to debug directly in the device. Do you know potentially what permission will that be?

 

In regarding to "menu item is being added from in the startup context", I assume if I need to add that through the event thread then I will need a user interface application to do so, correct?

 

I did look at the system log but can't seem to find anything meaningful.... 

Please use plain text.
Developer
RexDoug
Posts: 4,649
Registered: 07-21-2008

Re: Custom Menu showing up in simulator but not the actual device

If your applicaiton is "auto-run", then your app will be called during startup to take care of things like listeners, etc.

 

It will be called a second time when the user clicks on your icon, this time with a different parm and a different context.

 

If your app is not aust-start then you can ignore my comment.

 

I guess you are down to old-fashioned debugging. Put some trace println's in there and connect the device to the debugger.

 

 

Please use plain text.
Developer
jonberry
Posts: 470
Registered: 07-17-2008

Re: Custom Menu showing up in simulator but not the actual device

You need to sign the app with the Runtime API.
Please use plain text.
Developer
laurentC
Posts: 104
Registered: 02-05-2010
My Carrier: Bouygues Telecom

Re: Custom Menu showing up in simulator but not the actual device

I do have the same issue.

Did you find the solution ?

Twitter : @LaurentKP
My apps
Please use plain text.