Troubleshooting guide
149
9: Managing applications
Listen for changes to IT policies
Code example: Listening for changes to IT policies
Example: ITPolicyDemo.java
/**
* ITPolicyDemo.java
* Copyright (C) 2002-2005 Research In Motion Limited.
*/
package com.rim.samples.docs.itpolicy;
import net.rim.device.api.system.*;
import net.rim.device.api.itpolicy.*;
public class ITPolicyDemo extends Application implements GlobalEventListener {
public static void main(String[] args) {
ITPolicyDemo app = new ITPolicyDemo();
app.enterEventDispatcher();
}
ITPolicyDemo() {
this.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);
}
}
}
Managing code modules
A code module is a .cod file, the compiled archive of a single project in the BlackBerry® Integrated Development
Environment.
To retrieve information about and manage code modules on the BlackBerry device, use the CodeModuleManager
class in the
net.rim.device.api.system package.
Task Steps
Enable an application to use IT
policies.
> Implement the GlobalEventListener interface.
Identify changes in IT policies. > Implement GlobalEventListener.eventOccurred().