|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
The listener interface for receiving global events. Arbitrary applications may use global events for inter-process communication (IPC). The BlackBerry OS can also generate global events, such as those defined by the ServiceBook API. See the BlackBerry Application Developer Guide Volume 2: Advanced Topics for more information on ServiceBook global events.
To receive a global event, an application must implement the
net.rim.device.api.system.GlobalEventListener interface and implement the
GlobalEventListener.eventOccurred method, which is invoked when a global event
occurs. In its implementation of eventOccurred(), the application specifies
which actions to perform when a global event is received.
Register the GlobalEventListener by invoking the Application.addGlobalEventListener(GlobalEventListener) method.
Example 1: The following sample code demonstrates how to implement eventOccurred():
class ITPolicyDemo extends Application implements GlobalEventListener
{
public static void main(String[] args)
{
ITPolicyDemo app = new ITPolicyDemo();
app.enterEventDispatcher();
}
ITPolicyDemo()
{
addGlobalEventListener(this);
boolean appEnabled = ITPolicy.getBoolean("DemoAppEnabled", true);
System.out.println("App Enabled: " + appEnabled);
System.exit(0);
}
public void eventOccurred(long guid, int data0, int data1, Object obj0, Object obj1)
{
if ( guid == ITPolicy.GUID_IT_POLICY_CHANGED )
{
String security = ITPolicy.getString("DemoSecurityLevel");
boolean appEnabled = ITPolicy.getBoolean("DemoAppEnabled", true);
int retries = ITPolicy.getInteger("DemoAppRetries", 10);
}
}
}
Example 2: When the time zone changes, the system sends out a global event message to the
applications. To catch it, implement the GlobalEventListener interface and
register the listener by calling Application.addGlobalEventListener().
Your eventOccurred() method should look similar to this:
public void eventOccurred( long guid, int data0, int data1, Object object0, Object object1 )
{
if( guid == DateTime.GUID_TIMEZONE_CHANGED )
{
_cal.setTimeZone( TimeZone.getDefault() );
}
}
| Method Summary | ||
void |
eventOccurred(long guid,
int data0,
int data1,
Object object0,
Object object1)
Invoked when the specified global event occurred. |
|
| Method Detail |
public void eventOccurred(long guid,
int data0,
int data1,
Object object0,
Object object1)
The eventOccurred method provides two object parameters and two integer
parameters for supplying details about the event itself. The developer
determines how the parameters will be used.
For example, if the event corresponded to sending or receiving a mail message, the
object0 parameter might specify the mail message itself, while the
data0 parameter might specify the identification details of
the message, such as an address value.
guid - The GUID of the event.data0 - Integer value specifying information associated with the event.data1 - Integer value specifying information associated with the event.object0 - Object specifying information associated with the event.object1 - Object specifying information associated with the event.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.