Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Capture power change events

by Retired ‎02-12-2010 04:33 PM - edited ‎02-17-2010 10:12 AM (2,915 Views)


This article applies to the BlackBerry® wireless device based on Java™.


Your application can be notified when power change events take place on the BlackBerry device. This could be used to halt certain features when the battery power is low, and resume them when it is back to normal levels. Implementing the SystemListener interface (net.rim.device.api.system.SystemListener) can perform these operations. Events such as the BlackBerry powering on, powering off, and changes in the battery state can be captured. The following sample application shows how to implement the SystemListener interface:

* PowerChangeEvent.java

import java.util.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class PowerChangeEvent
extends Application implements SystemListener
public static PowerChangeEvent theApp;

public static void main(String args[])
theApp = new PowerChangeEvent();

public PowerChangeEvent()
//Register this instance with the system listener.
System.out.println("PowerChangeEvent: PowerChangeEvent has started!");

//Invoked when the user is putting the device into a power off state.
public void powerOff()
System.out.println("PowerChangeEvent: The BlackBerry is powering off.");

//Invoked when the device has left the power off state.
public void powerUp()
System.out.println("PowerChangeEvent: The BlackBerry is powering up.");

//Invoked when the internal battery voltage falls below a critical level.
public void batteryLow()
System.out.println("PowerChangeEvent: The battery is getting low!");

//Invoked when the internal battery voltage has returned to normal.
public void batteryGood()
System.out.println("PowerChangeEvent: The battery level is now good!");

//Invoked when the internal battery state has changed.
//Not used in this sample.
public void batteryStatusChange(int status)

Users Online
Currently online: 18 members 1,624 guests
Please welcome our newest community members: