BlackBerry Forums Support Community               

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

Please Login to Remove!

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
Offline  
Old 05-04-2007, 08:54 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: Proximus
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
Offline  
Old 05-04-2007, 11:01 AM   #3 (permalink)
Talking BlackBerry Encyclopedia
 
Join Date: Oct 2006
Model: 7103
Carrier: Verizon
Posts: 259
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
Offline  
Old 05-07-2007, 07:31 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: Proximus
Posts: 16
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!!
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





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