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
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: 16,987
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.