BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-15-2008, 06:30 PM   #1 (permalink)
BMF
New Member
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: att
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default PhoneCallLogID context is always Null in run() menu

Please Login to Remove!

Hi

I just started programming in the BlackBerry and I was trying to adapt the MenuItem Demo from JDE to add a menu item to the phone application, I would like to get information of the number that was dialed before, but when I select it the context variable is always null, in the menu run().

What am I doing wrong?

Code:
package com.rim.samples.menuitem;

import java.lang.*;
import java.util.*;
import net.rim.blackberry.api.menuitem.*;
import net.rim.blackberry.api.mail.*;
import net.rim.blackberry.api.pim.*;

//import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.blackberry.api.phone.*;
import net.rim.blackberry.api.phone.phonelogs.*;

/*
 * MenuItemDemo application
 * This registers a simple menu item with the system to be shown
 * when viewing an email Message. The run method for this menuItem
 * simply gets the message for use
 *
 * Copyright (C) 2003 Research In Motion Ltd.
 */

class MenuItemDemo {
    
    public static void main(String[] args){
        System.out.println("Starting MyMenuItemDemo");
        PhoneLogs _logs = PhoneLogs.getInstance();
        (new MyMenuItem(0)).registerInstance();
    }
}

class MyMenuItem extends ApplicationMenuItem
{
    private PhoneLogs _logs;
    
    // we'll use the default constructors here.
    MyMenuItem(int order){
        super(order);
    }

    // Register the instance of the menuItem with the system
    public void registerInstance(){
        System.out.println("Registering MyMenuItemDemo");
        _logs = PhoneLogs.getInstance();
        ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_PHONELOG_VIEW,this);
        ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_PHONE,this);
    }

    //methods we must implement
    //Run is called when the menuItem is invoked
    public Object run(Object context) {

        // Adding a breakpoint here context is always null!!!!
        if (context instanceof PhoneCallLogID) {
            try {
                PhoneCallLogID pCall = (PhoneCallLogID) context;
                Dialog.inform("Call to "+pCall.getNumber());
            } catch (Exception ex) {
                Dialog.alert(ex.getClass().getName() + ": " + ex.getMessage());
            }
        }

        return context;
    }

    //toString should return the string we want to
    //use as the lable of the menuItem
    public String toString(){
        return "My Menu";
    }

}
__________________
---
Do It Right or Don't do it at all.
Offline  
Old 03-16-2008, 03:27 PM   #2 (permalink)
New Member
 
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: vodafone
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem. It just doesn't work. I'm using 4.2.
Offline  
Old 03-17-2008, 05:50 AM   #3 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have to wait for 4.5, i had the same problem some time ago:
Quote:
Originally Posted by RIM Support
The specific scenario that you have reported seems fixed in v4.5 of the handheld code
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 03-17-2008, 06:25 AM   #4 (permalink)
CrackBerry Addict
 
Join Date: Jun 2005
Location: Manchester, UK
Model: BOLD
Carrier: t-mobile
Posts: 714
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

'seems' - that doesn't inspire confidence.
__________________
new job doesn't allow a public profile - please do not contact this user with questions, you will not get a response. good luck!
Offline  
Old 03-17-2008, 08:34 PM   #5 (permalink)
BMF
New Member
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: att
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

When will 4.5 be available for the handheld and emulator?
__________________
---
Do It Right or Don't do it at all.

Last edited by BMF : 03-17-2008 at 08:35 PM.
Offline  
Old 03-18-2008, 08:38 AM   #6 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

take a look at the speculation forum, can be out anytime soon.
all i can say is that my coworkers installed 4.5 on their devices on the CeBit.
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-12-2008, 12:10 PM   #7 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by BMF View Post
Hi

I just started programming in the BlackBerry and I was trying to adapt the MenuItem Demo from JDE to add a menu item to the phone application, I would like to get information of the number that was dialed before, but when I select it the context variable is always null, in the menu run().

What am I doing wrong?

Code:
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_PHONELOG_VIEW,this);
ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_PHONE,this);
You have registred two MenuItems, so only the second one works properly. As documented, it does not send any object to your application.

But I have no idea why a custom menu isn't registered in the phone log using MENUITEM_PHONELOG_VIEW field.
Offline  
Old 06-13-2008, 03:24 AM   #8 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

With firmware 4.5 you get some values from the menuitem - but not all. most important you do not get the result of a local addressbook search. no answer from rim support about this topic :(
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-25-2008, 11:11 AM   #9 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by simon.hain View Post
With firmware 4.5 you get some values from the menuitem - but not all. most important you do not get the result of a local addressbook search. no answer from rim support about this topic :(
So, it seems to be fixed! I mean the issue with MENUITEM registration in the call log.
Though it still does not work as documented. Using MENUITEM_PHONELOG_VIEW still has no effect, but item registred by MENUITEM_PHONE sends a PhoneLog instance to the application. It seems like bug - because acording documentation it mustn't happen!
Thus it is not bug but feature!
(I've used JDE 4.5.0.7 with built-in simulators).

Last edited by lePin : 06-25-2008 at 11:23 AM.
Offline  
Old 06-25-2008, 11:21 AM   #10 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

nice to know, i'll test it soon.
have to correct myself, i tested it with 4.6beta and it did not work correctly.

do you also get the contact if you look up a contact in the phone application and call the menu on the result?
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 06-25-2008, 04:35 PM   #11 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Posts: 13
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by simon.hain View Post
nice to know, i'll test it soon.
have to correct myself, i tested it with 4.6beta and it did not work correctly.

do you also get the contact if you look up a contact in the phone application and call the menu on the result?
What do you mean?
I have a contact when I pick out any line in the phone list (it does not matter, when the call was). But I have two interesting notes:
1. When I make a call to a phone number, then I add this number to the address book and after that I choose this line from the log - I receive the contact without Name, the Number only. Name is null. ))
2. If I change the Phone List View in the General Phone Options to any view type except Call Log the instance will equal to null.

Pavel

Last edited by lePin : 06-25-2008 at 04:37 PM.
Offline  
Old 06-27-2008, 04:42 AM   #12 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tested the issue using 4.5

when i enter a number i get a string as a context object (correct)
when i navigate on the call log i get a PhoneCallLog object (correct - was not working prior)
when i look up a name i get null as a context object (still not working)


the only thing the native phone application does better is looking up names, the API for this is unusably slow if there are more contacts in the addressbook. too bad you still can not use the native app via a menu entry :(
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-02-2008, 11:33 PM   #13 (permalink)
New Member
 
Join Date: Apr 2008
Model: none
PIN: N/A
Carrier: starhub
Posts: 11
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by lePin View Post
So, it seems to be fixed! I mean the issue with MENUITEM registration in the call log.
Though it still does not work as documented. Using MENUITEM_PHONELOG_VIEW still has no effect, but item registred by MENUITEM_PHONE sends a PhoneLog instance to the application. It seems like bug - because acording documentation it mustn't happen!
Thus it is not bug but feature!
(I've used JDE 4.5.0.7 with built-in simulators).
I observed the same. I am curious why menu item registered by MENUITEM_PHONE sends a PhoneLog instance to the application.. Why does it not return the selected contact instead?? What a feature..
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.