BlackBerryForums.com : Your Number One BlackBerry Community      

»Sponsored Links



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

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.
   
Reply With Quote
Sponsored Links
Please Login or Register to Remove these Advertisements!

  (#2 (permalink)) Old
jobsolle Offline
New Member
 
Posts: 6
Join Date: May 2007
Model: 8707
PIN: N/A
Carrier: vodafone
Default 03-16-2008, 02:27 PM

I have the same problem. It just doesn't work. I'm using 4.2.
   
Reply With Quote
  (#3 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 678
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 03-17-2008, 04:50 AM

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
   
Reply With Quote
  (#4 (permalink)) Old
jfisher Offline
CrackBerry Addict
 
jfisher's Avatar
 
Posts: 711
Join Date: Jun 2005
Location: Manchester, UK
Model: 8310
Carrier: t-mobile
Default 03-17-2008, 05:25 AM

'seems' - that doesn't inspire confidence.
   
Reply With Quote
  (#5 (permalink)) Old
BMF Offline
New Member
 
Posts: 2
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: att
Default 03-17-2008, 07:34 PM

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 07:35 PM.
   
Reply With Quote
  (#6 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 678
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 03-18-2008, 07:38 AM

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
   
Reply With Quote
  (#7 (permalink)) Old
lePin Offline
New Member
 
Posts: 13
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Default 06-12-2008, 11:10 AM

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.
   
Reply With Quote
  (#8 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 678
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 06-13-2008, 02:24 AM

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
   
Reply With Quote
  (#9 (permalink)) Old
lePin Offline
New Member
 
Posts: 13
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Default 06-25-2008, 10:11 AM

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 10:23 AM.
   
Reply With Quote
  (#10 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 678
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 06-25-2008, 10:21 AM

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
   
Reply With Quote
  (#11 (permalink)) Old
lePin Offline
New Member
 
Posts: 13
Join Date: Jun 2008
Model: 7100T
PIN: N/A
Carrier: none
Default 06-25-2008, 03:35 PM

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 03:37 PM.
   
Reply With Quote
  (#12 (permalink)) Old
simon.hain Offline
CrackBerry Addict
 
Posts: 678
Join Date: Apr 2005
Location: hamburg, germany
Model: 8700
Carrier: o2
Default 06-27-2008, 03:42 AM

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
   
Reply With Quote
  (#13 (permalink)) Old
samwize Offline
New Member
 
Posts: 11
Join Date: Apr 2008
Model: none
PIN: N/A
Carrier: starhub
Default 07-02-2008, 10:33 PM

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..
   
Reply With Quote
Reply


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 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.1