Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 13
Registered: ‎07-15-2008
My Device: Not Specified

Retrieve dialled number

Hi All,

 

I had posted ApplicationMenuItem issue with PhoneLog object being returned null in run() method.

 

http://www.blackberry.com/developers/forum/thread.jsp?forum=1&thread=14758&message=51067&q=nitin#51067

 

As suggested i have tried with 4.5 JDE also and still there is no solution. Infact same code which ran on 4.3 is not even hitting run() method on 4.5 JDE. In other words i am not entering into the run when i invoke by customized menuitem from default phone app. 

 

Do you think this may work directly on device of 4.3 (or 4.5 if there any device for 4.5 ?)

 

regards,

-nitin 

BlackBerry Development Advisor
Posts: 15,252
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Retrieve dialled number

The run method of your ApplicationMenuItem is not executed after you click on it in the menu?  Can you provide a code sample of your implementation?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Highlighted
Developer
Posts: 21
Registered: ‎07-16-2008
My Device: Not Specified

Re: Retrieve dialled number

Something I noticed is that the context object in 4.5 returns a string when you select from the dialing field and a phonecalllog otherwise for a menu item in the phone app.  It may not be executing the run method because it is throwing an exception for incompatible types.  I know I had to create two different handlers for the same menu item in 4.5 because of this.
New Developer
Posts: 13
Registered: ‎07-15-2008
My Device: Not Specified

Re: Retrieve dialled number

Hi Mark,

 

here is my code tested on 4.3 and 4.5 If control goes into run method following statement must execute

 

DemoAppMenuItem.EntNumber = "1234567";

 


package com.rim.samples.docs.menuitem;

import net.rim.device.api.system.*;
import net.rim.blackberry.api.menuitem.*;
import net.rim.blackberry.api.phone.*;
import net.rim.blackberry.api.invoke.*;
import net.rim.blackberry.api.phone.phonelogs.PhoneCallLog;

public final class DemoAppMenuItem extends Application
{
private static final String ARG_LAUNCH_PHONE_DEMO = "1";
public static String EntNumber = "414141";

public static void main(String[] args)
{
if (args == null || args.length == 0)
{
//for testing menuitem
DemoAppMenuItem app = new DemoAppMenuItem();
app.enterEventDispatcher();
}
else
{
String appToLaunch = args[0];
if(ARG_LAUNCH_PHONE_DEMO.equals(appToLaunch))
{
//testing outgoing call by invoking Phone app
//EntNumber = "987654321";
PhoneArguments call = new PhoneArguments(PhoneArguments.ARG_CALL, EntNumber);
Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, call);
}
//add more else ifs here
}
}

DemoAppMenuItem()
{
long locationToAddMenuItem = ApplicationMenuItemRepository.MENUITEM_PHONE;
addMenuItem(ARG_LAUNCH_PHONE_DEMO, locationToAddMenuItem, new DemoMenuItem());
System.exit(0);
}

private static void addMenuItem(String argOfAppl, long location, ApplicationMenuItem applMenuItem)
{
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
ApplicationDescriptor app = ApplicationDescriptor.currentApplicationDescriptor();
//set the argument so that we know which app we want to launch
app = new ApplicationDescriptor(app, new String[]{ARG_LAUNCH_PHONE_DEMO});
amir.addMenuItem(location, applMenuItem, app);
}

private static class DemoMenuItem extends ApplicationMenuItem
{
DemoMenuItem()
{
super(20);
}

public String toString()
{
return "NitinItem";
}

public Object run(Object context)
{
DemoAppMenuItem.EntNumber = "1234567";
PhoneCallLog c = (PhoneCallLog)context;
if ( c != null )
{
//DemoAppMenuItem.EntNumber = "1234567";
//DemoAppMenuItem.EntNumber = c.getParticipant().getNumber();
Application.getApplication().requestForeground();
//on invocation, will call the main method of this app. with argument as specified in addMenuItem
}
else
{
throw new IllegalStateException( "Context is null, expected a phonecalllog instance");
}
return null;
}
}
}

BlackBerry Development Advisor
Posts: 15,252
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Retrieve dialled number

The type of Object passed into the run method from an ApplicationMenuItem from the phone application varies based on the BlackBerry handheld software version in use.

 

Prior to version 4.3.0, it passes in a PhoneCallLog.

In version 4.3.0, null is passed in.

In version 4.5.0 a String containing the number is passed in.

In version 4.6.0 a PhoneCallLog is passed in.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker