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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Developer
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified
Accepted Solution

Detecting when screen goes black (sleep mode)

Is there a way to do this?  OnObscured doesn't seem to be called, which makes sense.  I wasn't able to find anything on the forums about this.

 

Thanks.

Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Detecting when screen goes black (sleep mode)

Systemlistener2
void backlightStateChange(boolean on)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 432
Registered: ‎02-23-2009
My Device: Not Specified

Re: Detecting when screen goes black (sleep mode)

You can use Backlight class for this. If you need to check whether backlight is on or off then you can use Backlight.isEnabled() or if you want to enable backlight (always or for specific time) then you can use Backlight.enable() and you can also set backlight timeout using Backlight.setTimeout().

 


If your problem was get solved then please mark the thread as "Accepted solution".
Press the kudos button to thank the user who helped you.

 

Deepesh Gupta
Highlighted
Developer
Posts: 696
Registered: ‎12-02-2008
My Device: Not Specified

Re: Detecting when screen goes black (sleep mode)

Hi,

 

I guess you want to know how application can detect when back light of the device is on/off.

 

There is an class for this with name "net.rim.device.api.system.Backlight"

 

It contains various method like isEnabled() which determines if the backlight is currently enabled or not.

 

I think you can use these methods.

 

Please let me know this solved your problem or not.

 

Regards,

Rajat Gupta.

_________________________________________________________________________________________________

If your issue solved, please resolve this thread. Set "Solution" mark on the post which contains the answer to your question. Thanks.Please If I successfully help you with an issue, thank you for clicking "kudos" in my post

Regards,
Rajat Gupta.
--------------------------------------------------------------------------------
If your problem was get solved then please mark the thread as "Accepted solution" and kudos - your wish
Developer
Developer
Posts: 167
Registered: ‎11-12-2008
My Device: Not Specified

Re: Detecting when screen goes black (sleep mode)

Thanks guys.  I actually realized that onVisibilityChange is what I'm looking for.  It is called when the screen goes black and when the screen is popped off the stack.