Custom menu item at the request of Message: two questions

I try to add a custom menu to the Blackberry message request and get two questions:

  1. When you click the custom menu, the "Application.getApplication () .requestForeground (); method call does not call the main() method of my application "DemoMI".
  2. If I changed the method of

Application.getApplication () .requestForeground)

TO

ApplicationManager.getApplicationManager () .runApplication (app); Where app is the "DemoMI" application descriptor

Will be called the main() method. However, how can I make the subject of the Message around in the method "run" for the application "com.demo.DemoApp"?  I tried to use a static variable 'mi ContactsDemoMenuItem', but I've always had "null" value when the "main()" is called.

My environment:

  • JDE: 4.2.0
  • Feature: Pearl 8100 with OS 4.2.0
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.Dialog.*;
import net.rim.blackberry.api.menuitem.*;
import net.rim.blackberry.api.pdap.*;
import javax.microedition.pim.*;
import net.rim.blackberry.api.mail.Message;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;

public final class DemoMI extends Application
{
    private static final String ARG_LAUNCH_CONTACT_DEMO = "1";
    private static  ContactsDemoMenuItem mi;
    public static void main(String[] args)
    {
        if(args == null || args.length == 0)
        {
            DemoMI app = new DemoMI();
            app.enterEventDispatcher();
        }else
        {
            String appToLaunch = args[0];
            if(ARG_LAUNCH_CONTACT_DEMO.equals(appToLaunch))
            {
               new com.demo.DemoApp(mi.getMessage()).enterEventDispatcher();
            }
        }
    }

    DemoMI()
    {
        long locationToAddMenuItem = ApplicationMenuItemRepository.MENUITEM_EMAIL_VIEW ;
        ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
        ApplicationDescriptor app = ApplicationDescriptor.currentApplicationDescriptor();

        app = new ApplicationDescriptor(app, new String[]{ARG_LAUNCH_CONTACT_DEMO});
        mi = new ContactsDemoMenuItem(app);
        amir.addMenuItem(locationToAddMenuItem, mi);
        System.exit(0);
    }

    private static class ContactsDemoMenuItem extends ApplicationMenuItem
    {
        ApplicationDescriptor app;
        Message msg;
        ContactsDemoMenuItem(ApplicationDescriptor app)
        {
            super(20);
            this.app = app;
        }

        public String toString()
        {
            return "My Menu Item";
        }

        public Message getMessage()
        {
            return msg;
        }      

        public Object run(Object context)
        {
            if ( context instanceof Message )
            {
                msg = (Message)context;
                try
                {

                    Application.getApplication.requestForeground();
                    //ApplicationManager.getApplicationManager().runApplication(app);
                }catch(Exception e)
                {
                    e.printStackTrace();
                }

             } else
             {
                throw new IllegalStateException( "Context is null, expected a Contact instance");
             }
             return null;
        }
    }
}

What you see is the expected behavior.  The ApplicationMenuItem runs in a different process where your application was run.  You have two options.

You can store the subject of the Message in the RuntimeStore when the ApplicationMenuItem is called.  Your application you are undertaking could then read the subject of the Message of the RuntimeStore.

Or you can create an application based on the drawing below:

How to allow - a listener in the background to detect and update a GUI application
Article number: DB-00406

http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800451/800783/How_To _...

Tags: BlackBerry Developers

Similar Questions

  • Getting context object null when using the custom menu item.

    Hi all

    I implemented a sample application to add menu item custom to the list of messages and we test this build on 9000 os 5.0.0.41 Blackberryy 1

    On BB 9000, we have 2 message inbox, A like Blackberry by default message inbox and B as long as the Inbox for the e-mail account, I have set up on BB 900.
    I implemented the menu custom application to add menu on the message list option.
    I see this option on both my inbox, the question that I am facing is when I click on the menu item by selecting the email in the message of default A Blackberry inbox I can get the context object were like when I click on the same message next to the Inbox B I'm always get the context as a NULL object.

    Below is the code I used to add the custom menu item.

    Public Shared Sub main (String [] args)
    {
    If (args! = null & args.length > 0) {}
    call from another entry point. Add menu items mark as Spam and mark as suspects.
    {if(args[0].) (Equals ("GUI"))}
    try {}
                            
    create menu items.

    MyMenu ApplicationMenuItem = new EmailFile();
    Add the menu item in the list view and send by e-mail.
    Amir ApplicationMenuItemRepository = ApplicationMenuItemRepository.getInstance ();
    amir.addMenuItem (ApplicationMenuItemRepository.MENUITEM_MESSAGE_LIST, mymenu);
    } catch (Exception e) {}
    Utility.debugLog (try (), CLASSNAME, 'hand', Utility.EXCEPTION_INFO);
    System.out.println("Error:"+e.ToString());)
    }
    } else {}
    show on the application of spam...
    AppMain _theApp = new AppMain();
    _theApp.enterEventDispatcher ();
    }
    } else {}
    show on the application of spam...
    AppMain _theApp = new AppMain();
    _theApp.enterEventDispatcher ();
    }
    }

    Can we know what is the problem in my code or something I'm missing.

    Thanks in advance.

    Navneet Gupta.

    application menu items have been bugged for ages. There is nothing you can do except change your workflow. in some cases, you can recover the app screen and trying to extract something of these fields, but becomes more difficult in the new OS versions because of custom fields used by rim.

  • Cannot create the custom menu item

    I feel that I'm missing something simple here.  Use the examples in the documentation for the BB developer, I am unable to get a custom menu item is displayed on a BB application menu in a simulator.

    More precisely:

    I copied the code for ContactsDemo (on page 31 of the PDF Advanced Developer) subjects, and works very well in the Simulator.

    I then copied the code for DemoAppMenuItem (from page 86 of the same doc).  It seems to work very well - no errors, and it appears in the Downloads folder on the Simulator.  But no custom menu item appears on the simulator when I create a new Contact, and then return to view it.

    I have all three options checked in Workspace Blackberry > Blackberry JDE > Code signing.

    My environment is:

    Eclipse 3.4.2

    BlackBerry JDE plugin 1.0.0.67 Eclipse

    I tried it with two simulators 4.5 and 4.6.

    Any suggestions are greatly appreciated!

    Thanks for the references page - this is a great compilation of resources!

    I don't know why the sample code of the documentation of EDGE does not work, but I was able to get the custom display menu item using the code I found this message on the forum.

  • dynamically create and destroy the custom menu item

    I have a standard TestStand platform that I use on multiple systems.  On some systems, I have a few sequences of calibration and I would like to have the Update menu to have the RunSequence of these sequences of calibration.  I know how to manually create these menu items, but they are no longer valid for some sequence files.  I would use the sequence SequenceFileLoad to dynamically create menu items and the SequenceFileUnload to destroy these menu items.

    I've played around with the API, but cannot determine the correct path to get to the create and destroy the custom menu items.  Does anyone know how this can be done?

    Thank you

    Matthew

    Yes, see the online help for the members of the following APIs:

    Engine.GetEditTimeToolMenuItems

    EditTimeMenuItems

    EditTimeMenuItem

    Basically, you get a collection of tool using Engine.GetEditTimeToolMenuItems () menu items and then call EditTimeMenuItems.Insert () or EditTimeMenuItems.Remove (). If you insert a you get returns an EditTimeMenuItem object on which you can change the settings.

    In addition, since it has an expression to hide items in menu tool, you need not necessarily to destroy, you can hide them instead.

    Hope this helps,

    -Doug

  • JavaScript: create menu buttons how custom toolbar items in the designer?

    Hello!

    Is it possible to create custom menu items or toolbar buttons in the ADEP/LiveCycle Designer?

    Thanks for the tips!

    Marcos

    Generally no,.

    but since the Designer ES2, you can create macros to simplify your workflow.

    These macros can be brought in the Tools menu.

    Here's a few macros that I did the Designer ES2 RPF / designer of the ADEP:

    http://thelivecycle.blogspot.com/search/label/macro

    For more databases on the macros to read the blog of John Brinkman.

    http://blogs.Adobe.com/formfeed/category/macros

  • How to add the menu item in the context menu of the Gallery

    Hi all

    I am new bie BlackBerrry development. Does anyone know how to add a menu item in the context menu of the BlackBerry Gallery. In other words, when I am browsing photos in the Gallery, click on the menu, there will be a configurable option so that my request will be executed when I select this item.

    Thank you
    TuanSandman

    See this article.

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800367/How_To _...

    Check the class ApplicationMenuItemRepository for applications where you can add the custom menu item.

  • Add a logo image to a custom menu item

    I created a new custom menu item 'Export' in adobe illustrator CS6.

    What I want to know is that is it possible to add a small logo along the side of the 'Export' text on this menu item in adobe illustrator CS6 as below next to the opening, printing etc..

    ss.png

    Without going through the SDK. You might be able to hack one using platform-specific menu calls, but I do not think that the SDK has something to help you map their handles for menuitem to the menu system handles.

  • Disable the menu item in the third party application (such as Photoshop)

    Please suggest me to disable the menu item in the third party application (such as Photoshop).

    Hello

    I suggest you to send your query to the following link:

    Photoshop Help Center: http://www.adobe.com/support/photoshop/

    Hope this information is useful.

  • How to a add a menu item for the depeneding menu existing email on the subject of the e-mail?

    Hi all...

    I'm new here and I need your help... Please

    I'm trying to add the menu item to the email existing menu depeneding on the email... I assumed using

    ApplicationMessageFolderRegistry togather with shops and Session but could not establish the code...

    any help please...

    Thank you

    Please mark the topic as solved, then.

  • Missing the Menu item in the import Panel?

    I am using LR3 for over a year - last version 3.6. Without apparent reason, the menu item "Do the second copy" no longer displays in the import Panel. Imported files are copied to the specified location the last time that the item was available. I looked in all the panels help, but don "t find any way to disable the second copy function, or to manage the second copy function. I'm Mac 10.6.8.

    Hugh,

    When you right-click on one of the headers Panel on the right side of the input dialogue, is "File management" checked? If not, click it or click "show all."

    HAL

  • Creating custom menu item

    Hi guys,.

    I am creating a menu item in the main menu of InDesign. Is this possible with *.jsx?

    The idea is to have the menu as follows: file | Change | Page layout | MyMenuGroup | Type of...

    Thank you!

    Insert this code into a startup script:

    try {}

    companyMainMenu=app.menus.item("$ID/Main").submenus.item ("company name");
    companyMainMenu.title;
    } catch (e) {}
    companyMainMenu=app.menus.item("$ID/Main").submenus.add ("company name");
    }
      
    var Script1 = new queue (SCRIPTS_PATH + "Configure.jsx");
    var ScriptAction1 is app.scriptMenuActions.add ("Configure");.
    var EventListener1 is ScriptAction1.eventListeners.add ("onInvoke", Script1, false);.
    var utilesScriptMenuItem1 = companyMainMenu.menuItems.add (ScriptAction1);
      
    var sub-menu; First level submenu
    try {}
    SubMenu = companyMainMenu.submenus.item ("submenu 1");
    SubMenu.title;
    } catch (e) {}
    SubMenu = companyMainMenu.submenus.add ("submenu 1");
    }
    var submenuScript1 = new File (SCRIPTS_PATH + "Action.jsx");
    var submenuScriptAction1 = app.scriptMenuActions.add ("Action");
    var submenuEventListener1 = submenuScriptAction1.eventListeners.add ("onInvoke", submenuScript1, f alse);
    var submenuScriptMenuItem1 = SubMenu.menuItems.add (submenuScriptAction1);

  • [JS CS4] Add menu item to the context menu of the control panel paragraph styles

    Hi all

    I am trying to add a menu item in the context menu of control panel of the paragraph styles, that appears when you right click on any paragraph style name in the Panel. But I can't find the menu in app.menus.

    In app.menus there is, for example, a 'Menu of the Pages panel framework', 'object Styles point context Menu. But there is no similar menu for the paragraph or character style.

    Someone help me?

    Paul

    RtMenuStyleListItem

  • How can we add a new menu item in the file Menu?

    Hello

    I want to create the menu item on the file Menu, I want to create a new menu item, just after the item "save under...". ». Is this possible with SDK?

    Thanks in advance

    Farida kaid

    You can file a new menuitem in any "menu group" defined by the Illustrator. If you look at AIMenuGroups.h, you will find the names of various groups of menuitems. There are two that might be what you want: kSaveForMenuGroup & kSaveMenuGroup. I can't remember how much control you have within a group, but it would at least allow you to get close enough.

  • Cannot open the HFM (grayed out menu items) in the workspace (weblogic\IIS)

    Hello

    Here is the configuration:

    HFM on IIS on server1. Port 80

    Planning on weblogic\IIS on server 2.

    Workspace on weblogic\IIS on the Server 3. Port 80.

    With this combination, I can see the menu items in the workspace of planning and can create an application. But the HFM as "Create app" menu items is gray and clicking on Sunrise an error that the module is not configured.

    If I rerun the configuration utility on the server (Server 3) workspace and workspace on weblogic\Apache (changed between IIS and apache), to deploy the two planning and HFM are at my disposal and I can create HFM applications.

    My client wants us to use IIS and also, we heard that support for Apache would be removed over time.

    Any ideas on how I can use IIS on the server to the workspace and get HFM to work with her.
    Another question is - can I change the port default HFM from 80 to something else while running the configuration tool for HFM.

    Thank you.

    Published by: user1658817 on June 10, 2009 17:24

    Published by: user1658817 on June 10, 2009 17:25

    I'll fly my answer on this topic from a previous post.

    It is useful to know what versions of the software on which you are working. I'll assume you're on the latest version.

    If you use a separate web server and application server and that you are not Apache as web server, you need to deploy the system of financial management. Please read the installation manual 52 next page: http://download.oracle.com/docs/cd/E12825_01/epm.111/epm_manual_deployment.pdf

    Alternatively, you can deploy the Web of HFM components directly to the server of the workspace that can be a little easier to install.

    Once you have chosen the direction chosen and made changes to the HFM, you will need to then to redeploy Workspace App Server and Configuration Web.

    Kind regards

    -John

  • can I add a menu item to the messaging application during execution (after the reading of the object and decide whether to add this menu item or not)?

    Hi all...

    can I add a mail application menu item when running...

    I want to open a mail, depending on its content, I want to decide whether to add an element or not or at least change the name of my customized according to the context of the email...?

    Please help anyone

    still no

Maybe you are looking for