BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links




Closed Thread
 
LinkBack Thread Tools
  (#1 (permalink)) Old
L Jorissen Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: Proximus
Default Hash code of package - 05-04-2007, 06:19 AM

Hi everyone,

I'm trying to get a menuitem in the BlackBerry messages and/or contacts application. I use the examples in the developer guides, but I can't get them to work. The menuitem doesn't show up in the applications. I use JDE 4.1 and JDE 4.2
My questions:
1) Is the code different for the different JDEs?
2) Why is the hash of the package name needed as stated in the BlackBerry App developer guide Vol 2 (Advanced topics) on page 85? And how to determine it?
3) Does anyone have a working example of it?

Any help would be extremely appreciated!!

Best regards and happy BB-ing
   
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
L Jorissen Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: Proximus
Default 05-04-2007, 08:54 AM

Hi again,

Here 's the code I mentioned above. Now you don't have to look it up in the developer guide

Code:
package com.rim.samples.docs.menuitem;

import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.Dialog.*;
import net.rim.blackberry.api.menuitem.*;
import javax.microedition.pim.*;
import net.rim.device.api.pdap.*;
//import com.rim.samples.docs.contactsdemo.*;

public final class DemoAppMenuItem extends Application {
    private static long ID = 0x7cab1e23b72a0033L; //hash of com.rim.samples.docs.menuitem
    
    public static void main(String[] args) {
        DemoAppMenuItem app = new DemoAppMenuItem();
        app.enterEventDispatcher();
    }

    DemoAppMenuItem() {
        ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
        amir.addMenuItem(ApplicationMenuItemRepository.MENUITEM_ADDRESSBOOK_LIST, new SampleMenuItem());
    }

    public class SampleMenuItem extends ApplicationMenuItem
    {
        SampleMenuItem() {
            super(20);
        }
        
        public String toString() {
            return "Give me more!";
        }
        
        public Object run(Object context) {
            //BlackBerryContact c = (BlackBerryContact)context;
            //if (c!=null) {
            //    new ContactsDemo().enterEventDispatcher();
            //} else {
            //    throw new IllegalStateException("Context is null, expected a contact instance.");
            //}
            net.rim.device.api.ui.component.Dialog.alert("Hello, you clikked the give me more menu item");
            return null; 
        }
    }
}


As you can see, I've commented out a piece of code, but put a dialog box instead.
Any suggestions to make it work?
   
  (#3 (permalink)) Old
bemshaswing Offline
Talking BlackBerry Encyclopedia
 
Posts: 220
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Default 05-04-2007, 11:01 AM

HI L Jorissen,
One thing comes to mind, for the menu item to be loaded into the menu, this application will have to be instantiated somewhere. Either you set it to load on startup, or you'll have to manually load it as a UIApplication, then it should appear in your menu.
   
  (#4 (permalink)) Old
L Jorissen Offline
Knows Where the Search Button Is
 
Posts: 16
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: Proximus
Default 05-07-2007, 07:31 AM

Hello bemshaswing,

Thank you for replying!
Allthough I tried changing the project properties and re-run before, this time it worked!!!

This is what I've done to make it work:
1) commented out the fifth import (...pdap.*)
2) commented out the ID (the hash I spoke about in a previous post)
3) changed the "Auto-run on startup" project property on tab "Application" to start up in tier 7

This made it work. On to the next problem
Thank's a million!!
   
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






Copyright © 2004-2008 BlackBerryNews.com, BlackBerryFAQ.com, BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of Research In Motion Limited.
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1