BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 03-26-2012, 06:13 PM   #1
yahoopitz
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
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
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
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
yahoopitz
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
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
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
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
yahoopitz
New Member
 
Join Date: Mar 2012
Model: 9930
PIN: N/A
Carrier: Verizon
Posts: 3
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
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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 06:52 AM
How to add a menu item into browser Confach General BlackBerry Discussion 0 03-18-2005 06:01 AM


CBB61 250V  Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF picture

CBB61 250V Capacitor 2 wires 1/2/3/3.5/4/5/6/7/8/9/10/12/15/18/20/24/25/30 UF

$129.95



6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF picture

6.3V 10V 16V 25V 35V 50V 100V 400V SMD Aluminum Electrolytic Capacitor 1-1000 UF

$155.59



45/5 MFD ±5% Dual Run Capacitor 370 450 VAC CBB65 AC Motor HVAC 45+5 uF Fan 10pk picture

45/5 MFD ±5% Dual Run Capacitor 370 450 VAC CBB65 AC Motor HVAC 45+5 uF Fan 10pk

$85.99



5pc Radial Electrolytic Capacitor 250V 100V 50V 25V 16V 0.22uF-4700uF 10000uF picture

5pc Radial Electrolytic Capacitor 250V 100V 50V 25V 16V 0.22uF-4700uF 10000uF

$27.99



10 MFD AC Capacitor, 10uF ±5% 370VAC/440 Volt Oval Run Start Capacitor picture

10 MFD AC Capacitor, 10uF ±5% 370VAC/440 Volt Oval Run Start Capacitor

$10.97



1/5pcs 100V~400V 0.1uF~100uF MKP Audio Metallized Polypropylene Film Capacitor picture

1/5pcs 100V~400V 0.1uF~100uF MKP Audio Metallized Polypropylene Film Capacitor

$63.90







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