Start the module for background processes or the module for the
UI
-
Import the required classes and interfaces.
import net.rim.blackberry.api.messagelist.*;
-
Create a main method for the
BlackBerry®
device application.
public static void main( String[] args )
{
try {
-
In
main(), check if the value of the
args parameter indicates that the application should
start the service module or the UI module.
if( args.length == 1 && args[ 0 ].equals( "service" ) )
{
}
} else if( args.length == 1 && args[ 0 ].equals( "gui" ) )
{
}
-
If the application should start the service module, in the first
if statement, create an instance of a class that
contains the service functionality and items. Obtain a reference to an
ApplicationMessageFolderRegistry object.
MLSampleService service = new MLSampleService();
ApplicationMessageFolderRegistry reg = ApplicationMessageFolderRegistry.getInstance();
-
If the application should start the UI module, in the
else if statement, create an instance of a class
that contains the UI functionality and items. For example, the UI module should
start if the
BlackBerry
device user clicks the application icon on the Home screen or opens a custom
message in the Messages application. Display the UI for the application and add
the application to the event dispatcher.
MLSampleGui gui = new MLSampleGui();
gui.showGui();
gui.enterEventDispatcher();
Code sample: Starting the module for background processes or the
module for the UI
import net.rim.blackberry.api.messagelist.*;
public static void main( String[] args )
{
try
{
if( args.length == 1 && args[ 0 ].equals( "service" ) )
{
MLSampleService service = new MLSampleService();
ApplicationMessageFolderRegistry reg =
ApplicationMessageFolderRegistry.getInstance();
}
else if( args.length == 1 && args[ 0 ].equals( "gui" ) )
{
MLSampleGui gui = new MLSampleGui();
gui.showGui();
gui.enterEventDispatcher();
}
}
}
Was this information helpful? Send us your comments.