Welcome!

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

Reply
Developer
bwei
Posts: 26
Registered: ‎07-14-2008
My Device: Not Specified
Accepted Solution

How to programmatically detect the the Lock screen is shown?

Does anyone have the idea to programmatically detect if the Lock Scrren is shown? I want to detect this screen so my application could do special Notifications.

 

Thanks fro your helps.

Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: How to programmatically detect the the Lock screen is shown?

You might try MemoryCleanerListener. You get a deviceLocked event when the screen is locked.

 

-de

 

 

 

Developer
bwei
Posts: 26
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to programmatically detect the the Lock screen is shown?

Thanks very much. My application just want to detect if the Lock Scrren is shown, but do not care this event (EVENT_DEVICE_LOCK).
BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: How to programmatically detect the the Lock screen is shown?

The ApplicationManager.isSystemLocked method can be used to determine if the BlackBerry is locked.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
bwei
Posts: 26
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to programmatically detect the the Lock screen is shown?

Mark, Thanks very much. This is what I am looking for.:smileyhappy:
New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Device: BB OS 7

Re: How to programmatically detect the the Lock screen is shown?

Anyone have successed with that code?
I still get the problem with it, this is my code, 

public static void main(String[] args)
    {
        MakeMeAPrincessApp theApp = new MakeMeAPrincessApp();       
        theApp.enterEventDispatcher();
        
        
      	MemoryCleanerDaemon.addListener(new MemoryCleanerListener() {
			public String getDescription() {
				// TODO Auto-generated method stub
				return "listener";
			}
			
			public boolean cleanNow(int event) {
				// TODO Auto-generated method stub
				System.out.println("running");
				if(event==MemoryCleanerListener.EVENT_DEVICE_LOCK){
					System.out.println("LOCK");
				}else{
					System.out.println("UNLOCK");
				}
				
				return false;
			}
		});
    }

 please anyone can help me?

Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: How to programmatically detect the the Lock screen is shown?

Hi @MalaWidiyanto

 

The function "enterEventDispatcher" does not return so you should add your listener (and all your code) before you call it.

 

E.

New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Device: BB OS 7

Re: How to programmatically detect the the Lock screen is shown?

hi @maadani thank for replay  :smileyhappy:
I have try to place the "listener" before "enterEventDispatcher" but its look doesn't work, 
do you have solution for this problem?

Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: How to programmatically detect the the Lock screen is shown?

Can you post your updated code?

 

What exactly happen when you are trying to debug your code?

 

Any errors in the log?

 

E.

New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Device: BB OS 7

Re: How to programmatically detect the the Lock screen is shown?

@maadani
this is my new code :

public static void main(String[] args)
    {
    	
    	MemoryCleanerDaemon.addListener(new MemoryCleanerListener() {			
			public boolean cleanNow(int event) {
				// TODO Auto-generated method stub
				System.out.println("running");
				if(event==MemoryCleanerListener.EVENT_DEVICE_LOCK){
					System.out.println("LOCK");
					Dialog.inform("LOCK");
				}else{
					System.out.println("UNLOCK");
				}
				
				return false;
			}

			public String getDescription() {
				// TODO Auto-generated method stub
				return "listener";
			}
		});
    	
      	MakeApp theApp = new MakeApp();       
        theApp.enterEventDispatcher();
    }

 but not successed yet, whats wrong with my code?
or I must try it in the device? I just tested it on Simulator :smileyvery-happy:

and no an error in the log ...