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
Developer
Jeff_Lu
Posts: 384
Registered: ‎08-12-2008
My Device: 8700
Accepted Solution

How to check if the application menuitem has already added to the application menu?

Hi All,

 

I want to insert some menutime to RIM application, for example,

 

I create a new Application menuitem named it customizedMenuitem and add it to RIM Message Application.

 

since everytime, when my application is being launced, it will add again.

 

So I want to check if it has already been added, if so, ignore to add it. if not, application will add again.

I have called removemenuitem before system.exit(0) when quiting my application, however it does not seem to work.:smileysad:

that is why I want to check menuitem before I add.

 

 

Source code like this,

 

Constructor()

{

    super();

    if(_appMenuitem is not added to RIM Application){

        create a new application menuitem

        ApplicationMenuItemRepostory.addMenuItem(int,applicationmenuitem)

    }

 

 Any words would be great appriciated!

 

Thanks in advanced!

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to check if the application menuitem has already added to the application menu?

The most common way to deal with this is to store a value in the Runtime Store.  Your application can save a value when it adds the ApplicationMenuItem, and then check to see if it is there when it is ran a second time.

 

The Runtime Store is erased when the BlackBerry is reset, which would also coincide with the ApplicationMenuItem being removed.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to check if the application menuitem has already added to the application menu?

I use the method recommended by Mark.  In RuntimeStore I actually put the ApplicationMenuItem I am adding.  Note that one must reference the actual menu item you added, if you want to remove it, so storing the ApplicationMenuItem  in RuntimeStore achieves two purposes

a) It is a 'flag', so that if it is in RuntimeStore, then I have Plenipotentiaries added the menu item

b) If I want to remove it, I can, using the ApplicationMenuItem in RuntimeStore when I issue my remove from the menu repository, then "nulling" the reference in RuntimeStore (to indicate it is no longer added!).

 

Hope this makes sense.

New Developer
sm3128
Posts: 7
Registered: ‎08-27-2008
My Device: Not Specified

Re: How to check if the application menuitem has already added to the application menu?

[ Edited ]
how can i add menuitem in the Addressbook which call my main customapplication.
Message Edited by sm3128 on 08-27-2008 06:45 AM
BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to check if the application menuitem has already added to the application menu?

Please have a look at this article.

 

How To - Add a custom menu item to an existing BlackBerry application
Article Number: DB-00110

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800367/How_To_...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
sm3128
Posts: 7
Registered: ‎08-27-2008
My Device: Not Specified

Re: How to check if the application menuitem has already added to the application menu?

 

 Thanx for replay i done it!

 

 My Question is, Is it necessary to create new project for to add customemenu in the Application menu item for at startup time.or is there any alternetive way.

 

Thankx and Regards,

 

sm3128

Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to check if the application menuitem has already added to the application menu?

Can I suggest that in future you ask a new question in a new Thread?

 

I would also suggest that you search the forum, and Knowledgebase before asking a question because often your question will already have been answered.  This will save you time because you will have the answer quicker!

 

In this case, I am sure a search on startup would have found this post:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&thread.id=3307

Developer
Jeff_Lu
Posts: 384
Registered: ‎08-12-2008
My Device: 8700

Re: How to check if the application menuitem has already added to the application menu?

Thanks you guys, I have got solution from your kind advice.

 

However, there is another question,

 

After application add a application menuitem to RIM Application.

if the user remove the application, and does not allow restart device, the menuitem will be left there.

and can not remove, I am not sure it will cause problem or not.

 

I have tested on my application, it works fine.

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,753
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to check if the application menuitem has already added to the application menu?

This is the expected behaviour.  Upgrading or uninstalling applications can require a reset of the BlackBerry.  The following link lists the reasons.

 

What Is - The reason a reset is required when upgrading an application
Article Number: DB-00602

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800620/What_Is...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker