BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-26-2012, 06:13 PM   #1 (permalink)
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help - Can't create a menu item!

Please Login to Remove!

*Figured it out

I am a first time developer and have been reading every tutorial and every javadoc I come accross (as well as all forum posts) on how to add a menu item to a native blackberry application, but I can't get it to work.

In this code, I am trying to add a button, "Text", to the menu when you're viewing an email, which will invoke a new SMS. On the line with the *, it returns this error:

Multiple markers at this line
- Syntax error on token ".", { expected
- Syntax error on token "getInstance", Identifier expected after this token

Here is the code:

import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.MessageArguments;
import net.rim.blackberry.api.mail.Message;
import net.rim.blackberry.api.menuitem.ApplicationMenuIte m;
import net.rim.blackberry.api.menuitem.ApplicationMenuIte mRepository;
import net.rim.device.api.ui.container.MainScreen;

public class Notes extends MainScreen{

MyMenuItem myMenuitem = new MyMenuItem(0);
* ApplicationMenuItemRepository.getInstance().addMen uItem(
ApplicationMenuItemRepository.MENUITEM_EMAIL_VIEW, myMenuitem);
}

class MyMenuItem extends ApplicationMenuItem{
MyMenuItem(int order){
super(order);
}

public Object run(Object context){
Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,
new MessageArguments( MessageArguments.ARG_NEW_SMS));

}

public String toString(){
return "TEXT";
}
}
}


What is wrong with this code? Any help would be GREATLY appreciated!

Last edited by yahoopitz : 03-26-2012 at 07:08 PM. Reason: Found a solution
Offline  
Old 03-27-2012, 06:53 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Please help - Can't create a menu item!

If you have "figured it out" then post the answer so anyone searching for a similar problem can find an answer instead of frustration.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 03-27-2012, 11:43 AM   #3 (permalink)
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Please help - Can't create a menu item!

Quote:
Originally Posted by hrbuckley View Post
If you have "figured it out" then post the answer so anyone searching for a similar problem can find an answer instead of frustration.
I added in a "physical app" to contain this code. So, on the homescreen there is my app to open, which then adds the menu.

However, every time I open the app, it adds ANOTHER button in the menu, instead of adding the button when the app is open, and removing it when it is closed. Any ideas?

Last edited by yahoopitz : 03-27-2012 at 12:21 PM.
Offline  
Old 03-27-2012, 12:54 PM   #4 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Please help - Can't create a menu item!

This is an instance where you will need to create a global singleton and only register the menu item when the singleton is created. Have a read through the following link and get back to me if you still have questions:
Sentenced to Life on a Technicality: BlackBerrry Singletons, Application Context and Threads
__________________
My other Blackberry is a PlayBook.
Offline  
Old 03-27-2012, 01:20 PM   #5 (permalink)
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: Please help - Can't create a menu item!

Thanks, hrbuckley. What I wound up doing instead was just making the app run on startup and then hiding the Application Icon so that the user would not click it again.

However, i`m not very familiar with RIM`s app policies. Is it alright to do it this way? Essentially, the menu item will not go away unless the app is uninstalled.
Offline  
Old 03-27-2012, 07:10 PM   #6 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: Please help - Can't create a menu item!

That is a bad idea. You will be wasting resources that way. I think you need to educate yourself a little more on the BlackBerry system or you'll end up writing yourself a pile of problems.
__________________
My other Blackberry is a PlayBook.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Please help - Can't create a menu item!
Thread Thread Starter Forum Replies Last Post
Double Calendar menu item? linklunk BlackBerry Help 1 11-04-2011 05:37 PM
Push a new screen on a menu item select - Beginner help karthikus Developer Forum 1 04-28-2010 08:20 AM
Menu item sonia1986 Developer Forum 1 09-14-2009 08:24 AM
Adding Menu Item into active connected call Hendrik2009 Developer Forum 1 02-24-2009 05:52 AM
How to add a menu item into browser Confach General BlackBerry Discussion 0 03-18-2005 05:01 AM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.