Troubleshooting guide

141
8: Creating notifications
Cancel events
Customize system notifications for immediate events
Task Steps
Cancel an immediate event. >Invoke cancelImmediateEvent(long, long, Object, Object), and then specify the
source and event ID.
NotificationsManager.cancelImmediateEvent(ID_1, 0, this, null);
Cancel a deferred event. >Invoke cancelDeferredEvent(long, long, Object, int, Object), and then specify
the source and event ID.
NotificationsManager.cancelDeferredEvent(ID_1, 0, this,
NotificationsConstants.MANUAL_TRIGGER, null);
Cancel all deferred events. If you invoke negotiateDeferredEvent() and do not specify a timeout, you must invoke
cancelDeferredEvent() to cancel the event or else the event never expires.
>Invoke cancelAllDeferredEvents(long, int, Object) to cancel all deferred events that
your application starts.
NotificationsManager.cancelAllDeferredEvents(ID_1,
NotificationsConstants.MANUAL_TRIGGER, null);
Task Steps
Respond to notification events. > Create a class that implements the Consequence and SyncConverter interfaces. The
SyncConverter interface defines the functionality necessary to convert data from object to
serialized format.
private static class ConsequenceImpl implements Consequence,SyncConverter
{...}
Define a unique ID. > Define a unique ID for the consequence.
public static final long ID = 0xbd2350c0dfda2a51L;
Define the constants. >Declare the DATA and TYPE constants to identify data for the application. When the application
invokes
convert(), the constants identify the type of incoming data from the SyncConverter.
private static final int TYPE = 'n' << 24 | 'o' << 16 | 't' << 8 | 'd';
private static final byte[] DATA = new byte[] {'m', 'y', '-', 'c',
'o', 'n', 'f', 'i', 'g', '-', 'o', 'b', 'j', 'e', 'c', 't'};
private static final Configuration CONFIG = new Configuration(DATA);
Create a tune that plays when the
BlackBerry® device user receives
the notification.
> Create a tune that plays as part of the consequence for event notifications.
private static final short BFlat = 466; // 466.16
private static final short TEMPO = 125;
private static final short d16 = 1 * TEMPO;
private static final short dpause = 10; // 10 millisecond pause
private static final short[] TUNE = new short[] {BFlat, d16, pause,
BFlat};
private static final int VOLUME = 80; // Percentage volume.