Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
frandelbetis
Posts: 42
Registered: ‎03-17-2012
My Device: Blackberry playbook
Accepted Solution

How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

[ Edited ]

Hello,

I´m developing an application that print email and I want to put a menu item in the emails with the option 'Print with....'. I use this:

 

PrintByMenuItem myMenuitem = new PrintByMenuItem(0);

ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_EMAIL_VIEW,
myMenuitem,ApplicationDescriptor.currentApplicationDescriptor());
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_EMAIL_EDIT,
myMenuitem,ApplicationDescriptor.currentApplicationDescriptor());
ApplicationMenuItemRepository.getInstance().addMenuItem(
ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST, myMenuitem,ApplicationDescriptor.currentApplicationDescriptor());

 

My application has two versions, with ads and without ads. When the user install the first version and then he want install the second version, the application will overwrite, and will have only one application in the device.

 

The problem is that, when I install the second version, the menu item 'Print with...' appear twice. How can I do to if a menu item exists in the email, doesn´t repeat the menuItem?

 

I´ve tried using removeMenuItem before to add menu item with:

 

ApplicationMenuItemRepository.getInstance().removeMenuItem(
ApplicationMenuItemRepository.MENUITEM_EMAIL_VIEW, myMenuitem);
ApplicationMenuItemRepository.getInstance().removeMenuItem(
ApplicationMenuItemRepository.MENUITEM_EMAIL_EDIT, myMenuitem);
ApplicationMenuItemRepository.getInstance().removeMenuItem(
ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST, myMenuitem);

 

but doesn´t work.

 

Thank you.

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

Does this happen on a device? Does the device reboot after you "upgrade" to the second version?

Please use plain text.
Contributor
frandelbetis
Posts: 42
Registered: ‎03-17-2012
My Device: Blackberry playbook

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

I´m in development phase, and I´m loading my app from Eclipse.

For example, in a Blackberry Bold, with OS 7.1, I´ve loaded the first version and then, without reboot the device, I´ve loaded the second version. The option 'Print with...' appears twice...

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

This is not how it would work in production/on device. Once the device reboots, the menu item will be removed from the repository and you will have one menu item.

 

However, if you exit your app and start again (if you register the menu items on startup of the app) the you will have duplications as well. If this is not the case, then you shouldn't have to worry.

 

If this is the case, then I suggest your store a runtime veriable as a check to ensure no duplication.

Please use plain text.
Developer
simon_hain
Posts: 16,216
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

you can either add the menu item on startup (alternate entry point) or store it in the runtimestore and check if it already exists.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
frandelbetis
Posts: 42
Registered: ‎03-17-2012
My Device: Blackberry playbook

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

Yes, I´ve controlled the no duplication when I exit my app and start again.

And yes, I´ve seen that when I reboot the device the duplicate item disappears.

So, the question is: In production phase, when an user download my app with ads, install it, and then download the app without ads, and install it, the device will reboot automatically  and doesn´t appears duplicate items?

 

Thank you.

Please use plain text.
Developer
simon_hain
Posts: 16,216
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

yes
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
frandelbetis
Posts: 42
Registered: ‎03-17-2012
My Device: Blackberry playbook

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

simon_hain, if I store in runtime store, when this variable is deleted? When I delete my app?

Please use plain text.
Developer
Dionysus
Posts: 152
Registered: ‎07-28-2011
My Device: Bold 9900

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

it will be deleted whenever the phone reboots.

Please use plain text.
Contributor
frandelbetis
Posts: 42
Registered: ‎03-17-2012
My Device: Blackberry playbook

Re: How can I do to if a menu item exists, doesn´t repeat the menuItem when I install other version of the app?

Thank you both.:smileywink:

Please use plain text.