11-18-2010 07:23 AM
Hi,
I need to detect if the user press the lock button on the top left of BB (is a 8900 bold).
I read in a post that there isn't a specific listener but is possible to detect it implementing a MemoryCleanerListener because as RIM say:
"By default, the memory cleaner application runs on a BlackBerry® device when the BlackBerry device is inactive for a specified period of time. You or a BlackBerry device user can change when the memory cleaner application runs when any the following conditions exist:
MemoryCleanerDaemon.addListener(new MemoryCleanerListener() {
public String getDescription() {
return "listener";
}
public boolean cleanNow(int event) {
if (event==MemoryCleanerListener.EVENT_DEVICE_LOCK){
//do something
}
return false;
}
Solved! Go to Solution.
11-18-2010 11:54 AM
Hi,
I resolve the problem moving the MemoryCleanerDaemon.addListener after the enterEventDispatcher.
The MemoryCleanerListener working and using ApplicationManager method isSystemLocked I know when the user press to lock and when to unlock
Best regards
04-17-2011 09:49 PM
Does it work well in os 5.0 or 6.0?Or are you do it in os 5.0 or 6.0?
# I tried to change the world, but I couldn't find the source code #
06-07-2011 06:21 AM - edited 06-07-2011 06:41 AM
egirotto wrote:Hi,
I resolve the problem moving the MemoryCleanerDaemon.addListener after the enterEventDispatcher.
The MemoryCleanerListener working and using ApplicationManager method isSystemLocked I know when the user press to lock and when to unlock
Best regards
if you move emoryCleanerDaemon.addListener after the enterEventDispatcher. MemoryCleanerDaemon.addList
i dont know how you got it working. enterEventDispatcher will make main thread to listen for the UI events right?
After entering to event listening it wont come back to execute MemoryCleanerDaemon.addListener right?
any one please help me. i want to know when user presses lock button. I used following code but not getting the event. Even if i place MemoryCleanerDaemon.addListener before theApp.enterEventDispatcher() also i am not getting the event. please help.
public static void main( String[] args ) {
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
HelloBlackBerry theApp = new HelloBlackBerry();
theApp.enterEventDispatcher();
MemoryCleanerDaemon.addListener(new MemoryCleanerListener() {
public boolean cleanNow(int event) {
if(event==MemoryCleanerListener.EVENT_DEVICE_LOCK) {
//do something
System.out.println("EVENT_DEVICE_LOCK");
}
System.out.println("--------------------EVENT_DEVI CE_LOCK---------------------------------------");
return false;
}
public String getDescription() {
// TODO Auto-generated method stub
return "listener";
}
});
}
02-28-2013 03:53 AM
I have the same problem, anyone can help us to solve it? please ![]()
02-28-2013 07:25 PM
I have solve my similar problem with this methode :
- Backlight.isEnable()
- Backlight.enable(false);
- Backlight.enable(true);
check this out : http://www.blackberry.com/developers/docs/5.0.0api