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

Display a PopupScreen from a SendListener

by BlackBerry Development Advisor ‎02-16-2010 11:59 AM - edited ‎02-17-2010 03:42 PM (3,294 Views)


This article applies to the following:

  • BlackBerry® smartphones based on Java®


The SendListener interface can be triggered by a foreground application that displays a GUI (such as the Messages application or a third-party application) or by a background application or process that does not contain a GUI (such as a third-party application or when appointment invitations are sent from the Calendar application). Each case requires a different approach to display a PopupScreen to the BlackBerry smartphone user, resulting in the SendListener detecting what type of application is triggering it and displaying the PopupScreen appropriately. Failing to do so can result in the PopupScreen not being shown to the BlackBerry smartphone user.

The following code example demonstrates how to detect the type of application triggering the SendListener and how to display a Dialog for each case.

public class MySendListener extends Application implements SendListener
public boolean sendMessage(Message msg)
Dialog myDialog = new Dialog(Dialog.D_OK,
"This is a Message from a SendListener",
//Override inHolster to prevent the Dialog from being dismissed
//when a user holsters their BlackBerry. This can
//cause a deadlock situation as the Messages
//application tries to save a draft of the message
//while the SendListener is waiting for the user to
//dismiss the Dialog.

public void inHolster()

//Obtain the application triggering the SendListener.
Application currentApp = Application.getApplication();

//Detect if the application is a UiApplication (has a GUI).
if( currentApp instanceof UiApplication )
//The sendMessage method is being triggered from
//within a UiApplication.
//Display the dialog using is show method.
//The sendMessage method is being triggered from
// within an application (background application).
Ui.getUiEngine().pushGlobalScreen( myDialog, 1,

return true;

Users Online
Currently online: 17 members 3,712 guests
Please welcome our newest community members: