MenuItem, duplication on ApplicationMenuItemRepository

Hi guys!

I'm creating an application is adds a MenuItem to the menu system.

This means that it will be visible in all applicactions.

Everything works fine, but there is a small problem.

When you enter the application (via the application in the bb menu icon), a configuration screen will appear.

Everything is fine, except that MenuItem creates and adds to the Menu system, once again... and if you close and open the configuration screen, it happens again... and so on...

I tried to use the AddMenu as a thread as a background application, but it continues to be.

Here is my sample code...

any ideas?

Main application class:

public class MyApp extends UiApplication{

    private BackgroundClass bgThread;

    public static void main(String[] args){
        MyApptheApp = new MyApp();
        theApp.enterEventDispatcher();
    }

    public MyApp()
    {
        bgThread = new BackgroundClass();
        bgThread.start();
        pushScreen(new ConfigScreen());
    }

    protected void onExit()
    {
        bgThread.stop();
    }
}

Thread class:

public class BackgroundClass extends Thread {
    MenuItem myMenuItem = new MenuItem(0);

    public void run()
    {
        ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM,myMenuItem);
    }

    public synchronized void stop()
    {
        ApplicationMenuItemRepository.getInstance().removeMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM,myMenuItem);
    }

}

The ConfigScreen class has nothing about it, so it is useless to post...

Any ideas?

Thanks in advance!

See you soon!

RuntimeStore store = RuntimeStore.getRuntimeStore();
String msg = "item1";
long ID = 0x60ac754bc0867248L;                     

Object obj = store.get(ID);
if(obj == null)
{

MenuItemClass menuItem = new kMenuItemClass(0,this);                                        

ApplicationMenuItemRepository repository =  ApplicationMenuItemRepository.getInstance(); 

long id = ApplicationMenuItemRepository.MENUITEM_PHONE;
repository.addMenuItem(id, menuItem);
try
{
 store.put( ID, msg );
} catch(IllegalArgumentException e)
{
}

}

Tags: BlackBerry Developers

Similar Questions

  • ApplicationMenuItemRepository:removeMenuItem does not delete added proviously MenuItem

    Hello

    I use following code for in my MIDlet startup() adds a MenuITem to BlackBerry menu

                    //////////////////////////////////////////////////////////////////////               net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository repository = net.rim.blackberry.api.menuitem.ApplicationMenuItemRepository.getInstance();
                    GlobalMenuItem smi = new GlobalMenuItem();
    
    //to remove previously added Item - But it always returns false
                    boolean b = repository.removeMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM, smi);               
    
                    repository.addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM, smi);
                    //////////////////////////////////////////////////////////////////////
    

    But each time you launch the app I see keep seal the MenuITem in the BlackBerry HomeScreen menu. removeMenuItem doesn't seem to work? Whats wron?

    He would remove the menu correctly - item but the menu item is not yet added.

    to remove the previous menu item you would need a reference to it.

    I suggest using the runtimestore or an Autostart entry point.

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

    Hello

    I m developing an application printing 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 or no ads. When the user to install the first version and then they want to install the second version, the application will overwrite and will be only one application in the device.

    The problem is that when I install the second version, the menu item 'print with... '. ' appears twice. How can I do to if a menu item exist in enamel, doesn´t repeat the menuItem?

    I ve tried using removeMenuItem before adding the 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 works.

    Thank you.

    This is not how it would work production / the device. After restarting the device, the menu item will be deleted from the repository, and you will have a menu item.

    However, if you leave your app and try again (if you save the menu items at the application startup) the you'll thus duplication. If this isn't the case, then you should not worry.

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

  • Launch of the MenuItem Application

    public AppMainScreen()
    {
    
        int placement = 0x350100;
        ApplicationMenuItem ami = new ApplicationMenuItem(placement)
        {
           public Object run(Object context)
           {
              try
              {
                       new App().enterEventDispatcher(); 
    
              }
              catch (Exception e)
              { 
    
              }
              return null;
    
               }
    
           public String toString()
           {
               return "Launch Application";
           }
        };
    
           ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
    
    amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM, ami); 
    
    }
    

    Hi people, I've added a MenuItem to the "overall MenuItem" to launch the my request (ApplicationMenuItemRepository.MENUITEM_SYSTEM).

    But when I click on MenuItem, my application is not launched.

    new App().enterEventDispatcher(); 
    

    App is the class that contains the main method.

    Any thoughts on this people? Thank you...

    use applicationmanager.launch

  • Add menuitem to a third-party application

    Hi all

    I try to add a menuitem to a third party application, for example facebook, but I can't find a way to do it. I use ApplicationMenuItemRepository.MENUITEM_SYSTEM but not what I want because even though I can see the menu item in facebook I can also see it everywhere else and I don't want that, I just want to see the menu item in facebook. Is there a way to do this? Facebook is an example, may be twitter, or any application.

    Thanks in advance

    No, this is not possible.

  • How we prevent multiple similar menuitem added in messaging app?

    Hi all

    I have an application that would add a menu item to the email messaging application using this call that move on the startup application:

    Amir ApplicationMenuItemRepository = ApplicationMenuItemRepository.getInstance ();
    amir.addMenuItem (ApplicationMenuItemRepository.MENUITEM_EMAIL_EDIT, new myAppItem (0));

    If my app run several times then it displays several items menu like on the Menu of the Email app. Do you know if there is a way for me to check if a menu item is already added so that the code and check and not to add the menu item for the second time?

    Thank you.

    Answer in this thread, I think.

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

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&message.ID=3157

  • app iCloud and photos of duplication

    First, I copied my photo library on a disk (that has been synchronized with my iCloud account).

    Then, I just did a clean Sierra install for my MacBook.

    After that find my photo library with App Photos.

    And open iCloud photo library.

    Photos app started to redownload all the same pictures to my mac book.

    So I duplicated photos now.

    How can I stop it duplication?

    (I have 13 000 photos close to 50 GB)

    The only one I know is through a third-party application.

    There are a few duplicate programs that are tested as safe with Photos, including PowerPhotos, PhotoSweeper for the pictures and Duplicate Annihilator for Photos - do not use a tested and documented as safe.

  • Duplication of any libraries - any way to merge?

    Hello

    In my 'Images' folder, I have now two libraries - iPhoto Library and photo library.  Having considered the two libraries there is a lot of overlap and duplication between them, and as they both occupy about 110 GB each I will refine them.  Y at - it a simple way to merge libraries, removing duplicate images in the process?

    Incidentally, I just opened the iPhoto library in iPhoto and recalled iPhoto how elegant has been compared to its replacement teen Photos - this is the progress apparently

    John

    You can remove whatever library is not in use (probably iPhoto) but you will not regain a lot of space. The two libraries use the same set of images, which are the bulk of the size.

  • Steps and distance of duplication of the iphone and Apple Watch

    Hi, I would like to know how to disable back into shape and the movement for enforcement of health on my iphone affects the calculations of distance and stage of Apple Watch. IM turning off this option because I found his duplication my distance and steps. My Apple Watch will cease to use my iPhone's gps location?

    I know health app must analyze the data a prioritize my Apple Watch. Instead, his duplication in the info on my iphone and Apple Watch. Im not using third party applications. I do not fear the deactivation of the fitness and followed by my iphone only if my Apple Watch will receive my iphone gps information when I workout.

    Hello

    Health and fitness of the Apple Watch data, iPhone and all the other sources are grouped within the app to health on the iPhone, which allows to adjust the results to avoid any double counting of data from different sources.

    When several sources are available, the application of health uses a single data source for updating your consolidated data. This source is selected according to the order of priority that you set (or that was created automatically - for example, by default, rank devices Apple above sources third party).

  • Apple TV apps duplication on iPad

    The apps that I download on the app store by Apple TV are simultaneously also download on my ipad. Some do not have even a peer iOS so they at first do not offer an 'X' If you want to remove them.

    How can I stop this download duplication doesn't happen?

    Thank you.

    Some Apple TV apps are universal apps with versions of iOS for iPad and iPhone. If you have automatic downloads enabled on all iOS devices apps universal downloaded on ATV4 will appear on your iOS devices. For this you can go in setting disable and 'iTunes and App Store' on the iPad and disable the cursor Apps for automatic downloads.

  • Is it possible after duplication of tracks to merge automatically?

    After duplication and slide on a track I always have to pick up the pieces, and then move the duplicate above so that it matches the original in piano roll. Is there a way in a double track to get automatically merge in time with the original? There is always a gap between the original and the copy, and I have to manually move the notes in piano mode so that it matches the original. Even if make a loop by dragging the region there is a space between the original and the copy. For me is not really a loop if there is a break between the original and the loop before it repeats. Thanks in advance for your help. I have searched but can't find the answer I was looking for.

    The notes should be moved is continuous.

  • Playlists of duplication, do not sync

    Lately, whenever I sync my iPod to my iTunes library, I had the problem of the playlists of duplication just instead of synchronization for how I changed on my computer. It has become incredibly frustrating because in order to sync my iPod, I have to take an hour to remove duplicates and versions of the playlists on my iPod how I want them.

    Had the same problem. It seemed occurs more often when I na not give enough time to the iDevice to synchronize first on iCloud. Nothing seemed to help, but it finally disappeared.

    Find the Apple of the problem here: http://www.apple.com/feedback/

  • In trying to move the photos to the key, I've accidentally moved into my office - they kept sort of duplication and there is 7 000 or them - how to remove the easily?

    Mac Pro 10.11.4 17 "

    In trying to move photos to the key, accidentlaly I moved into my office - they kept sort of duplication and there is 7 000 or them - how to remove the easily? I've been

    Open your desktop folder in the Finder, then type 'image' in the search field in the Finder window toolbar and value of the research for "kind: Image".

    Define the scope of the search for "Desktop".

    Now, you can select all items in the window by entering ⌘A, then drag the photos in your Inbox.

    Check a second time, that the scope of the research really is 'Office' and not 'this computer '.

  • Photo duplication of photos from Iphoto? (Events/albums)

    Hello

    Yesterday I upgraded my Macbook pro to El Capitan, my main concern was and is still, the migration to photos from Iphoto, given that my library is 200 GB +. So far, that the migration seemed to work very well, but I worried amb a little overlap.

    In Iphoto, I had all my photos in events and I also made albums selection of photos of these events, I was convinced that the pictures on these albums were not duplications and that Iphoto created somehow links to original photos into events.

    Now that I've migrated to the Photo, so my old albums and my events appear under the same albums category. Therefore, I have the albums I created and another folder called Iphoto events, which is also an album. Does this mean that the photos in the albums I created with Iphoto are duplicated and taking a double space in my SSD? Thank you

    Gerard

    both my old albums and my events appear under the same albums category. Therefore, I have the albums I created and another folder called Iphoto events, which is also an album. Does this mean that the photos in the albums I created with Iphoto are duplicated and taking a double space in my SSD? Thank you

    Everything you see in the section Album do not duplicate photos and more storage.

    Photos does not all events, so migration created albums of events as the note for you, how your events had been grouped and named. But all the photos in the folder "iPhoto events" are just standard albums and using the photos already in the library.

    Pictures uses 'moments' to partition the library rather than events.  Each photo that you import will appear in just a moment. You have only the duplicates, if you see the same photo twice in the library, and the second version has a different file name.

  • Add MenuItem icon in Webworks

    Hello...

    I would like to add the image icon to a MenuItem, but I do not know how...
    I do not have any code.

    Please help me... if anyone has code or advice please share...

    Unfortunately not possible with the right WebWorks, you must write a custom extension to do it for you. More details on this here http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/Building-a-BlackBerry-WebWorks-J...

    (a list of the currently available API community: https://github.com/blackberry/WebWorks-Community-APIs/tree/master/Smartphone)

Maybe you are looking for