Troubleshooting guide

137
8: Creating notifications
Code sample:
Example: NotificationsDemo.java
/**
* NotificationsDemo.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.docs.notifications;
import net.rim.device.api.notification.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.util.*;
public class NotificationsDemo extends UiApplication
{
public static final long ID_1 = 0xdc5bf2f81374095L;
private long _eventIdGenerator;
private static Object er;
public static final Object event = new Object() {
public String toString() {
return “Sample Notification Event #1”;
}
};
public static void main(String[] args) {
if ( args.length > 0 && args[0].equals( “autostartup” ) ) {
NotificationsManager.registerSource(ID_1, event,
NotificationsConstants.CASUAL);
NotificationsManager.registerConsequence(ConsequenceDemo.ID, new
ConsequenceDemo());
} else {
NotificationsDemo app = new NotificationsDemo();
app.enterEventDispatcher();
}
Perform initializations at the
alternative entry point.
Make sure that the string checked in the If statement matches the value you type in the Arguments
passed to field in the BlackBerry IDE project.
>In your main() method, perform any required initializations.
public static void main (String[] args) {
if ( args.length > 0 && args[0].equals(“autostartup”)) {
//Application runs as a system module at startup.
//Perform any necessary one-time automatic initialization.
} else {
//Application is being run by a user.
}
}
Task Steps