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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
bwei
Posts: 26
Registered: ‎07-14-2008
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.

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008

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

 

 

 

Please use plain text.
Developer
bwei
Posts: 26
Registered: ‎07-14-2008

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).
Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
My Carrier: Bell

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.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Developer
bwei
Posts: 26
Registered: ‎07-14-2008

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

Mark, Thanks very much. This is what I am looking for.:smileyhappy:
Please use plain text.
New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Carrier: BB 9900

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?

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

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.

Please use plain text.
New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Carrier: BB 9900

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?

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011

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.

Please use plain text.
New Contributor
MalaWidiyanto
Posts: 6
Registered: ‎02-28-2013
My Carrier: BB 9900

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 ...

Please use plain text.